If you connect to the MDB database in a Linux system and connect directly, the MDB default driver does not recognize the non-Windows path, so you cannot use a regular connection
Way
Driver={microsoft Access DRIVER (*.mdb)};D Bq=c:\\dir\\file.mdb
Installation
Here we need to use some libraries to implement third-party drivers
We need to install these packages: Mdbtools, UnixODBC, LIBMDBODBC
If you cannot find LIBMDBODBC in a system that supports Deb, add the following path to the list of software sources
Deb Http://ftp.de.debian.org/debian Squeeze Main
After you update the source, you can install LIBMDBODBC.
Configuration
After installing the required packages, you need to do some configuration to support the LIBMDBODBC driver.
Copy the Code code as follows:
/etc/odbcinst.ini
[MDBTOOLSODBC]
Description = MDB Tools ODBC
Driver =/usr/lib/libmdbodbc.so.0
Setup =
FileUsage =
CPTimeout =
Cpreuse =
/etc/odbc.ini or ~/.odbc.ini
Copy the Code code as follows:
[Test]
Description = Microsoft Access Try DB
Driver = Mdbtoolsodbc
Database =/path/to/mdb/file/test.mdb
Servername = localhost
Username =
Password =
Port = 5432
Code
Once the data source is configured, it can be used in any application that supports ODBC access, with PYODBC as an example
#-*-coding:utf-8-*-import pyodbcconn = pyodbc.connect (' dsn=test '); cursor = Conn.cursor () cursor.execute (' SELECT * FROM "Save" ') for Row in Cursor.fetchall (): Print row. Name
Note: If the name of the Chinese table or field, and so on, you need to include it in double quotation marks, or it will be wrong, of course, the table name into Chinese so two, or not recommended to use
Pyodbc is a very good library, API is also very useful, but the Chinese support is not good, it does not default to Unicode processing data, so for Chinese-related applications, coding problems everywhere, had to slowly toss.