ODBC
Adapter
/ODBC Adaptor
ODBC, open Database Connectivity, is an integral part of the database in the Microsoft Open Service Architecture (Wosa,windows Open Services Architecture), which establishes a set of specifications and provides a set of standard APIs (application programming interfaces) for database access. These APIs use SQL to accomplish most of their tasks. ODBC itself also provides support for the SQL language, which allows users to send SQL statements directly to ODBC.
1 ODBC Environment Configuration /ODBC Configuration
Python package with ODBC installed
Refer to the links for configurations that PYODBC connect to different databases.
1. Connect SQL Server:driver={sql Server};
2. Connect mysql:driver={mysql ODBC 5.x Driver} to install MySQL ODBC:
3. MySQLdb
No need to install MySQL ODBC,
Currently the Linux version supports to the 2.7,windows version support to 2.5.
4. Installation of PYODBC under Linux
Need to install UNIXODBC,FREETDS,MYSQL-CONNECTOR-ODBC
5. Use of PYODBC under Linux
PYODBC does not support using the following connection method in Linux
S=pyodbc.connect ('driver={sql Server}; Server=127.0.0.0;database=test; Uid=test; Pwd=test')
The proper way to connect MSSQL on Linux is
S=pyodbc.connect ('Driver={freetds}; Server=127.0.0.0;database=test; UID=IDC; Pwd=test')
2 ODBC connecting to a database /ODBC Connect Database
use PYODBC to connect to the database,
1 ImportPyodbc as ODBC2 3 defConnect (* *Kwargs):4CNX = Odbc.connect (* *Kwargs)5Cur =cnx.cursor ()6Sql='SELECT * from INFORMATION_SCHEMA. TABLES'7 cur.execute (SQL)8Re =Cur.fetchall ()9 Print(RE)Ten cur.close () One cnx.close () A -Connect (host=' Host', user='User', password='Password', database='DB', charset='UTF-8', driver='SQL Server') - the #Connect (host= ' localhost ', user= ' root ', password= ' root ', charset= ' UTF-8 ', driver= ' MySQL ODBC 5.3 driver ')
Note: SQL Server was successfully connected using ODBC here, but it has not been successfully connected to MySQL
Related reading
1. Using Python to build a MySQL adapter
2. DB-API General Standard
Reference Links
Https://zhidao.baidu.com/question/1050890691174410619.html
http://sourceforge.net/projects/mysql-python/
ODBC adapter/DB-API, database interface, Python and database [1]