ODBC adapter/DB-API, database interface, Python and database [1]

Source: Internet
Author: User
Tags odbc

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.