连接器和 API

数据库连接器为客户端提供了连接数据库服务端的方式,APIs 提供了使用 MySQL 协议和资源的底层接口。无论是连接器还是 API,都可以用来在不同的语言和环境内连接服务器并执行 sql 语句,包括 odbc、java(jdbc)、Perl、Python、PHP、Ruby 和 C。

TiDB 兼容 MySQL(5.6、5.7) 的所有连接器和 API,包括:

使用 MySQL 连接器连接 TiDB

Oracle 官方提供了以下 API,TiDB 可以兼容所有这些 API。

使用 MySQL C API 连接 TiDB

如果使用 C 语言程序直接连接 TiDB,可以直接链接 libmysqlclient 库,使用 MySQL 的 C API,这是最主要的一种 C 语言连接方式,被各种客户端和 API 广泛使用,包括 Connector/C。

使用 MySQL 第三方 API 连接 TiDB

第三方 API 非 Oracle 官方提供,下表列出了常用的第三方 API:

Environment API Type Notes
Ada GNU Ada MySQL Bindings libmysqlclient See MySQL Bindings for GNU Ada
C C API libmysqlclient See Section 27.8, “MySQL C API”.
C++ Connector/C++ libmysqlclient See MySQL Connector/C++ Developer Guide.
MySQL++ libmysqlclient See MySQL++ Web site.
MySQL wrapped libmysqlclient See MySQL wrapped.
Go go-sql-driver Native Driver See Mysql Go API
Cocoa MySQL-Cocoa libmysqlclient Compatible with the Objective-C Cocoa environment. Seehttp://mysql-cocoa.sourceforge.net/
D MySQL for D libmysqlclient See MySQL for D.
Eiffel Eiffel MySQL libmysqlclient See Section 27.14, “MySQL Eiffel Wrapper”.
Erlang erlang-mysql-driver libmysqlclient See erlang-mysql-driver.
Haskell Haskell MySQL Bindings Native Driver See Brian O'Sullivan's pure Haskell MySQL bindings.
hsql-mysql libmysqlclient See MySQL driver for Haskell.
Java/JDBC Connector/J Native Driver See MySQL Connector/J 5.1 Developer Guide.
Kaya MyDB libmysqlclient See MyDB.
Lua LuaSQL libmysqlclient See LuaSQL.
.NET/Mono Connector/Net Native Driver See MySQL Connector/Net Developer Guide.
Objective Caml OBjective Caml MySQL Bindings libmysqlclient See MySQL Bindings for Objective Caml.
Octave Database bindings for GNU Octave libmysqlclient See Database bindings for GNU Octave.
ODBC Connector/ODBC libmysqlclient See MySQL Connector/ODBC Developer Guide.
Perl DBI/DBD::mysql libmysqlclient See Section 27.10, “MySQL Perl API”.
Net::MySQL Native Driver See Net::MySQL at CPAN
PHP mysql, ext/mysqlinterface (deprecated) libmysqlclient See Original MySQL API.
mysqli, ext/mysqliinterface libmysqlclient See MySQL Improved Extension.
PDO_MYSQL libmysqlclient See MySQL Functions (PDO_MYSQL).
PDO mysqlnd Native Driver
Python Connector/Python Native Driver See MySQL Connector/Python Developer Guide.
Python Connector/Python C Extension libmysqlclient See MySQL Connector/Python Developer Guide.
MySQLdb libmysqlclient See Section 27.11, “MySQL Python API”.
Ruby MySQL/Ruby libmysqlclient Uses libmysqlclient. See Section 27.12.1, “The MySQL/Ruby API”.
Ruby/MySQL Native Driver See Section 27.12.2, “The Ruby/MySQL API”.
Scheme Myscsh libmysqlclient See Myscsh.
SPL sql_mysql libmysqlclient See sql_mysql for SPL.
Tcl MySQLtcl libmysqlclient See Section 27.13, “MySQL Tcl API”.

TiDB 支持的连接器版本

Connector Connector version
Connector/C 6.1.0 GA
Connector/C++ 1.0.5 GA
Connector/J 5.1.8
Connector/Net 6.9.9 GA
Connector/Net 6.8.8 GA
Connector/ODBC 5.1
Connector/ODBC 3.51 (Unicode not supported)
Connector/Python 2.0
Connector/Python 1.2