2018-05-10 an attempt on Trumigrate tools and how python connect with ms access

User interface: 

2018-05-10 an attempt on Trumigrate tools and how python connect with ms access_第1张图片


2018-05-10 an attempt on Trumigrate tools and how python connect with ms access_第2张图片

Connecting to Microsoft Access

Gord Thompson edited this page on Mar 4, 2017 · 11 revisions


Microsoft only produces Access ODBC drivers for the Windows platform. Third-party vendors may be able to provide Access ODBC drivers for non-Windows platforms.

There are actually two (2) different Access ODBC drivers from Microsoft:

Microsoft Access Driver (*.mdb) - This is the older 32-bit "Jet" ODBC driver. It is included as a standard part of a Windows install. It only works with .mdb (not .accdb) files. It is also officially deprecated.

Microsoft Access Driver (*.mdb, *.accdb) - This is the newer "ACE" ODBC driver. It is not included with Windows, but it is normally included as part of a Microsoft Office install. It is also available as a free stand-alone "redistributable" installer for machines without Microsoft Office. There are separate 64-bit and 32-bit versions of the "ACE" Access Database Engine (and drivers), and normally one has either the 64-bit version or the 32-bit version installed. (It is possible to force both versions to exist on the same machine but it is not recommended as it can "break" Office installations. Therefore, if you already have Microsoft Office it is highly recommended that you use a Python environment that matches the "bitness" of the Office install.)

The easiest way to check if one of the Microsoft Access ODBC drivers is available to your Python environment (on Windows) is to do

>>>importpyodbc>>>[xforxinpyodbc.drivers()ifx.startswith('Microsoft Access Driver')]

If you see an empty list then you are running 64-bit Python and you need to install the 64-bit version of the "ACE" driver. If you only see ['Microsoft Access Driver (*.mdb)'] and you need to work with an .accdb file then you need to install the 32-bit version of the "ACE" driver.

Here is an example of how to open an MS Access database:

conn_str=(r'DRIVER={Microsoft Access Driver(*.mdb,*.accdb)};'r'DBQ=C:\path\to\mydb.accdb;')cnxn=pyodbc.connect(conn_str)crsr=cnxn.cursor()fortable_infoincrsr.tables(tableType='TABLE'):print(table_info.table_name)

Unit Tests

There are unit tests for Python 2 and 3: tests2\accesstests.py and tests3\accesstests.py

For each, you need to pass in the name of an access file that can be used. Empty ones you can test with are provided: tests2\empty.mdb and tests2\empty.accdb.


https://stackoverflow.com/questions/1047580/ms-access-library-for-python

2018-05-10 an attempt on Trumigrate tools and how python connect with ms access_第3张图片

https://stackoverflow.com/questions/12761236/connection-to-access-from-python

2018-05-10 an attempt on Trumigrate tools and how python connect with ms access_第4张图片

你可能感兴趣的:(2018-05-10 an attempt on Trumigrate tools and how python connect with ms access)