Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python ODBC connection: not a valid file name error

I am new to Python and have been assigned the task to copy all the MS Access database files(we have five) into CSV format using Python. I have searched through lots of posts on Stack Overflow and sketched together this amateur snippet. I need to see the files I have in my MS Access database. Can someone please provide assistance.

Pyodbc Error - Python to MS Access

open access file in python

import pyodbc

conn_string = ("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=T:\\DataDump\\7.18.2016 PCR etrakit.accdb") 

conn = pyodbc.connect(conn_string)

cursor = conn.cursor()

cursor.close()
conn.close()

print 'All done for now'

1 Answers

[UPDATED]Try running this

conn_string = ("DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\T:\\DataDump\\7.18.2016 PCR etrakit.accdb")

use double backslash instead.

like image 141
Shubham R Avatar answered Dec 20 '25 21:12

Shubham R