Mailing List Archive

Connecting to MS accdb and read data into Pandas
I tried the following code:
import pyodbc

conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb,
*.accdb)};DBQ=D:\my.accdb;')
cursor = conn.cursor()
cursor.execute('select * from table_name')

for row in cursor.fetchall():
print (row)


But I could not connect to .accdb.

What is the robust way to set the connection string?

Regards,

David
--
https://mail.python.org/mailman/listinfo/python-list
Re: Connecting to MS accdb and read data into Pandas [ In reply to ]
On 2021-10-12 09:40, Shaozhong SHI wrote:
> I tried the following code:
> import pyodbc
>
> conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb,
> *.accdb)};DBQ=D:\my.accdb;')
> cursor = conn.cursor()
> cursor.execute('select * from table_name')
>
> for row in cursor.fetchall():
> print (row)
>
>
> But I could not connect to .accdb.
>
> What is the robust way to set the connection string?
>
What does the traceback say?
--
https://mail.python.org/mailman/listinfo/python-list