corinna
corinna

Reputation: 649

Using Python to manipulate an Access database protected with UserName and Password

I have to work with a MS Access DB where I can insert and modify data manually via GUI. The GUI opens with execution of an .mde file which prompts for UserName and Password.

Of course, I have no DB admin rights. I also have no admin rights for my system. I am using 32-bit Python on 64-bit Windows 7.

Now my question:

Is there a possibility to access the .mdb file via command line in order to integrate data / change data automatically?

(Pythonic solutions would be appreciated.)

Upvotes: 0

Views: 6569

Answers (1)

Gord Thompson
Gord Thompson

Reputation: 123839

Since you are using 32-bit Python on Windows you can simply use or and the Microsoft Jet ODBC driver. The connection string you will need to use will be of the form

connStr = (
    r"Driver={Microsoft Access Driver (*.mdb)};"
    r"Dbq=C:\whatever\mydatabase.mdb;"
    r"SystemDB=C:\whatever\mydatabase.mdw;"
    r"UID=yourUserName;"
    r"PWD=yourPassword;"
    )

Notes:

  1. For 64-bit Python you would have to use 64-bit version of the newer Microsoft Access Database Engine (a.k.a. "ACE") and Driver={Microsoft Access Driver (*.mdb, *.accdb)}.

  2. The SystemDB parameter could be omitted if the database in question uses the default System Workgroup to manage UserNames and Passwords. The default System Workgroup file is named "system.mdw" and is located in either the "%APPDATA%\Microsoft\Access\" or "%windir%\system32\" folder.

Upvotes: 2

Related Questions