Forums

Using pyodbc on local files

Hi there:

I've using PythonAnywhere for a while, and I love it and their community

This time I want to deploy a Django application but I am stucked because this app uses pyodbcto read LOCALLY STORED Microsoft Access Files (.accdb).

These are the lines involved:

conn_str = "DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ=<PATH_TO_ACCDB>;"
conn = pyodbc.connect(conn_str)

I tried to follow the instructions for connecting to MS SQL Server but I had two other problems there.

1-. In pyodbc instructions, it says we should create some files in home folder. This "home folder" refers to /home or /home/MY_USERNAME? The former doesn't work for me because I don't have enough permissions.

2-. Steps 2 and 3 don't make sense to me because I am not accessing to a remote DB, I am only reading locally stored files.

I followed the first step (creating odbcinst.ini in /home/MY_USERNAME) but I keep getting this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

P.D: I also ran os.environ["ODBCSYSINI"] = "/home/MY_USERNAME".

Any idea?

Microsoft only provide Access ODBC Drivers for WIndows, so this will never work on PythonAnywhere. See https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-Microsoft-Access

Hi,

Were you able deploy your website using pyodbc? I have similar app with the same error...

Thanks

No, that will not work.