Microsoft Access Database connecting from Python through ODBC

Henrik Weber Henrik.Weber at sys.aok.de
Fri Dec 6 04:26:35 EST 2002


"Jeremie Legault" <jlegault at impathnetworks.com> wrote in message news:<YROH9.8175$rv5.1174930 at news20.bellglobal.com>...
> I wonder if anyone knows how to format the login string to connect to a
> Microsoft Access Database through ODBC. If I open a shell and test my code
> it connects without needing a user ID and password. However if I connect
> through a CGI script (python is invoked by the CGI request) I can not
> connect to the database. I tried adding the
> 'DSN=OwnDatabase;UID=Mikkon;PWD=abcde' but this returns errors. I believe it
> works when I invoke the program because I am logged in with an account that
> has valid permission to interact with the database.
> 

Remember that Access doesn't store account information in the
database, but in a separate file that's used for all Access sessions
independent of the database until you select another one. The default
file is called SYSTEM.MDW and is stored in a Common Files directory
somewhere. If you created the database while using a different .MDW
file when you created the database, you will have to include the path
to that file in your connection string. I don't know what the right
syntax for that is with ODBC because I'm using ADO for the purpose.
There the syntax is something like this:

'<all the other stuff>;Jet OLEDB:SystemDatabase=C:\Program
Files\Common Files\System\system.mdw'

Maybe there is a corresponding thing for ODBC connections.

Cheers

Henrik Weber



More information about the Python-list mailing list