I am unable to write this df into the access table. What am I not doing right?
conn_str = (
r'DRIVER={Microsoft Access Driver (*.mdb)};'
r'DBQ=C:\Users\harsh\Desktop\Database1.mdb;'
)
cnxn = pyodbc.connect(conn_str)
SQL = 'SELECT * FROM Index_data;'
dfins = pd.read_sql(SQL, cnxn)
for index, row in dfins.iterrows():
with cnxn.cursor() as crsr:
crsr.execute('select * from df')
conn.commit()
You probably have not installed ODBC driver for MS Access, or its name
"Microsoft Access Driver (*.mdb)"
don't agree with the string used in your program — for newer versions of Microsoft Access it is
"Microsoft Access Driver (*.mdb, *.accdb)"
.
So verify its name, or install it:
Open Control Panel , select Administrative Tools , then ODBC Data Sources .
New window will open up. Select “User DSN” tab.
Then verify the driver name, or install an appropriate Microsoft Access Driver — see for example Steps to create a New ODBC Connection on Windows 10 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.