How To Create A Mdb File From A Csv File In Python?
I have several csv files that I need to transfer over to mdb format. I tried the answer in this post as a starting point: How do you create a mdb database file in Python? Source: f
Solution 1:
First thing I would suggest is upgrading to python 2.7 if at all possible.
Second, have you tried win32com
?
Here's a test script that does what you have above:
import win32com.client
import os
defmain():
db_path = r'C:\temp.mdb'if os.path.exists(db_path):
os.remove(db_path)
db_eng = win32com.client.gencache.EnsureDispatch("DAO.DBEngine.36")
db = db_eng.CreateDatabase(db_path, win32com.client.constants.dbLangGeneral)
db.Execute("CREATE TABLE test (ID Text, numapples Integer)")
db.Execute("INSERT INTO test VALUES ('ABC', 3)")
db.Close()
if __name__ == '__main__':
main()
Solution 2:
You haven't got Access installed on the computer on which this script is running.
Solution 3:
Try PyPyODBC, it can be as easy as:
import pypyodbc
pypyodbc.win_create_mdb( "D:\\Your MDB file path.mdb" )
https://code.google.com/p/pypyodbc/wiki/pypyodbc_for_access_mdb_file
Post a Comment for "How To Create A Mdb File From A Csv File In Python?"