0

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()

Error Datasource not found

1 Answer 1

1

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:

  1. Open Control Panel, select Administrative Tools, then ODBC Data Sources.

  2. 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.