2

I'm attempting to connect to an Access .mdb database with Python pyodbc. I connect to a local database, and this works fine. The database contains linked tables to a back end .mdb on a network drive. I receive this error when attempting to select from the linked table:

pyodbc.Error: ('HY024', "[HY024] [Microsoft] [ODBC Microsoft Access Driver] 'U:\OFFICE\GIS\accessdatabase.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. (-1023) (SQLExecDirectW)")

The path name is correct, and the linked tables work fine if I go into my local database and open them. The python program never mentions the network database or it's path at all, it only connects to the local database.

The python script works fine. I'm only getting the error when running the compiled .exe generated by Pyinstaller. Also, a coworker can compile on Windows 10 and his .exe works fine. But it has to compile on Windows 7 to produce an .exe that works on Windows 7.

Windows 7.

conn_str = (
            r'DRIVER={Microsoft Access Driver (*.mdb)};'
            r'Uid=Admin;Pwd=;'
            r'DBQ=' + self.path
            )

Any assistance or pointers would be greatly appreciated! Thanks

3
  • Are you running the compiled exe while logged in under your normal user account (so you have drive letters mapped as expected)? Commented Aug 10, 2018 at 20:51
  • 1
    I am. However while trying to figure out the issue, I have noticed that if I open command prompt as administrator and call NET USE, the network drives are unavailable. I found this and think the problem is related: support.microsoft.com/en-us/help/937624/… Commented Aug 10, 2018 at 21:11
  • Try using forward slashes. Commented Aug 10, 2018 at 22:20

1 Answer 1

1

Not sure if this is an answer exactly, or more of a work around, but I got it to work by re-linking the remote database tables using '\server\name\path' style paths in the local database, instead of 'U:\path' style ones. Apparently the compiled program was trying to run as administrator for some reason, and in command window the mapped drives were unavailable when running as administrator. Figured I would share in case anyone else has a similar issue.

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.