简体   繁体   English

使用Python操纵受用户名和密码保护的Access数据库

[英]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. 我必须使用MS Access DB,可以在其中通过GUI手动插入和修改数据。 The GUI opens with execution of an .mde file which prompts for UserName and Password. GUI打开并执行.mde文件,提示输入用户名和密码。

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. 我在64位Windows 7上使用32位Python。

Now my question: 现在我的问题是:

Is there a possibility to access the .mdb file via command line in order to integrate data / change data automatically? 是否可以通过命令行访问.mdb文件以自动集成数据/更改数据?

(Pythonic solutions would be appreciated.) (Pythonic解决方案将不胜感激。)

Since you are using 32-bit Python on Windows you can simply use or and the Microsoft Jet ODBC driver. 由于您在Windows上使用32位Python,因此只需使用以及Microsoft Jet ODBC驱动程序即可。 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 (aka "ACE") and Driver={Microsoft Access Driver (*.mdb, *.accdb)} . 对于64位Python,您必须使用64位版本的较新的Microsoft Access数据库引擎 (又名“ ACE”),并且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. 如果所讨论的数据库使用默认的系统工作组来管理用户名和密码,则可以省略SystemDB参数。 The default System Workgroup file is named "system.mdw" and is located in either the "%APPDATA%\\Microsoft\\Access\\" or "%windir%\\system32\\" folder. 默认的系统工作组文件名为“ system.mdw”,位于“%APPDATA%\\ Microsoft \\ Access \\”或“%windir%\\ system32 \\”文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM