Table of Contents
- 27.1 MySQL Connector/C++
- 27.2 MySQL Connector/J
- 27.3 MySQL Connector/NET
- 27.4 MySQL Connector/ODBC
- 27.5 MySQL Connector/Python
- 27.6 libmysqld, the Embedded MySQL Server Library
- 27.7 MySQL C API
- 27.7.1 MySQL C API Implementations
- 27.7.2 Example C API Client Programs
- 27.7.3 Building and Running C API Client Programs
- 27.7.4 C API Data Structures
- 27.7.5 C API Function Overview
- 27.7.6 C API Function Descriptions
- 27.7.7 C API Prepared Statements
- 27.7.8 C API Prepared Statement Data Structures
- 27.7.9 C API Prepared Statement Function Overview
- 27.7.10 C API Prepared Statement Function Descriptions
- 27.7.11 C API Threaded Function Descriptions
- 27.7.12 C API Embedded Server Function Descriptions
- 27.7.13 C API Client Plugin Functions
- 27.7.14 C API Encrypted Connection Support
- 27.7.15 C API Multiple Statement Execution Support
- 27.7.16 C API Prepared Statement Handling of Date and Time Values
- 27.7.17 C API Prepared CALL Statement Support
- 27.7.18 C API Prepared Statement Problems
- 27.7.19 C API Automatic Reconnection Control
- 27.7.20 C API Common Issues
- 27.8 MySQL PHP API
- 27.9 MySQL Perl API
- 27.10 MySQL Python API
- 27.11 MySQL Ruby APIs
- 27.12 MySQL Tcl API
- 27.13 MySQL Eiffel Wrapper
MySQL Connectors provide connectivity to the MySQL server for client programs. APIs provide low-level access to the MySQL protocol and MySQL resources. Both Connectors and the APIs enable you to connect and execute MySQL statements from another language or environment, including ODBC, Java (JDBC), Perl, Python, PHP, Ruby, and native C and embedded MySQL instances.
Oracle develops a number of connectors:
Connector/C++ enables C++ applications to connect to MySQL.
Connector/J provides driver support for connecting to MySQL from Java applications using the standard Java Database Connectivity (JDBC) API.
Connector/NET enables developers to create .NET applications that connect to MySQL. Connector/NET implements a fully functional ADO.NET interface and provides support for use with ADO.NET aware tools. Applications that use Connector/NET can be written in any supported .NET language.
MySQL for Visual Studio works with Connector/NET and Microsoft Visual Studio 2012, 2013, 2015, and 2017. MySQL for Visual Studio provides access to MySQL objects and data from Visual Studio. As a Visual Studio package, it integrates directly into Server Explorer providing the ability to create new connections and work with MySQL database objects.
Connector/ODBC provides driver support for connecting to MySQL using the Open Database Connectivity (ODBC) API. Support is available for ODBC connectivity from Windows, Unix, and macOS platforms.
Connector/Python provides driver support for connecting to MySQL from Python applications using an API that is compliant with the Python DB API version 2.0. No additional Python modules or MySQL client libraries are required.
For direct access to using MySQL natively within a C application, there are two methods:
The C API provides low-level access to the MySQL client/server protocol through the
libmysqlclientclient library. This is the primary method used to connect to an instance of the MySQL server, and is used both by MySQL command-line clients and many of the MySQL Connectors and third-party APIs detailed here.
libmysqlclientis included in MySQL distributions.
libmysqldis an embedded MySQL server library that enables you to embed an instance of the MySQL server into your C applications.
libmysqldis included in MySQL distributions.Note
libmysqldembedded server library is deprecated as of MySQL 5.7.19 and will be removed in MySQL 8.0.
To access MySQL from a C application, or to build an interface to MySQL for a language not supported by the Connectors or APIs in this chapter, the C API is where to start. A number of programmer's utilities are available to help with the process; see Section 4.7, “Program Development Utilities”.
The remaining APIs described in this chapter provide an interface to MySQL from specific application languages. These third-party solutions are not developed or supported by Oracle. Basic information on their usage and abilities is provided here for reference purposes only.
All the third-party language APIs are developed using one of two
libmysqlclient or by implementing
a native driver. The two
solutions offer different benefits:
libmysqlclientoffers complete compatibility with MySQL because it uses the same libraries as the MySQL client applications. However, the feature set is limited to the implementation and interfaces exposed through
libmysqlclientand the performance may be lower as data is copied between the native language, and the MySQL API components.
Native drivers are an implementation of the MySQL network protocol entirely within the host language or environment. Native drivers are fast, as there is less copying of data between components, and they can offer advanced functionality not available through the standard MySQL API. Native drivers are also easier for end users to build and deploy because no copy of the MySQL client libraries is needed to build the native driver components.
Table 27.1, “MySQL APIs and Interfaces” lists many of the libraries and interfaces available for MySQL.
Table 27.1 MySQL APIs and Interfaces
|Ada||GNU Ada MySQL Bindings||
||See MySQL Bindings for GNU Ada|
||See Section 27.7, “MySQL C API”.|
||See MySQL Connector/C++ 8.0 Developer Guide.|
||See MySQL++ website.|
||See MySQL wrapped.|
||Compatible with the Objective-C Cocoa environment. See http://mysql-cocoa.sourceforge.net/|
|D||MySQL for D||
||See MySQL for D.|
||See Section 27.13, “MySQL Eiffel Wrapper”.|
|Haskell||Haskell MySQL Bindings||Native Driver||See Brian O'Sullivan's pure Haskell MySQL bindings.|
||See MySQL driver for Haskell.|
|Java/JDBC||Connector/J||Native Driver||See MySQL Connector/J 5.1 Developer Guide.|
|.NET/Mono||Connector/NET||Native Driver||See MySQL Connector/NET Developer Guide.|
|Objective Caml||OBjective Caml MySQL Bindings||
||See MySQL Bindings for Objective Caml.|
|Octave||Database bindings for GNU Octave||
||See Database bindings for GNU Octave.|
||See MySQL Connector/ODBC Developer Guide.|
||See Section 27.9, “MySQL Perl API”.|
||See Original MySQL API.|
||See MySQL Improved Extension.|
||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||
||See MySQL Connector/Python Developer Guide.|
||See Section 27.10, “MySQL Python API”.|
|Ruby/MySQL||Native Driver||See Section 27.11.2, “The Ruby/MySQL API”.|
||See Section 27.12, “MySQL Tcl API”.|