Client drivers for YSQL API
The Yugabyte Structured Query Language (YSQL) API builds upon and extends a fork of the query layer from PostgreSQL 11.2, with the intent of supporting most PostgreSQL functionality and adding new functionality to supported distributed SQL databases.
For details on PostgreSQL feature support in YSQL, see What Features Does YSQL Support?
Yugabyte and third party client drivers listed below are supported for developing applications that connect to and interact with the YSQL API. Most of the drivers use libpq and support the SCRAM-SHA-256 authentication method.
For help using these drivers with YSQL, ask your questions in the Slack community.
If you encounter an issue or have an enhancement request, file a GitHub issue.
C
libpq
libpq
is the C client library for connecting to and interacting with PostgreSQL databases. libpq
is also the underlying engine used in other PostgreSQL application interfaces. The libpq
client library also supports the SCRAM-SHA-256 authentication method.
For details and documentation, see libpq - C Library
for PostgreSQL 11, which YugabyteDB is based on.
For a tutorial on building a sample C application with libpq
, see Build a C application.
To install the libpq client library
The libpq
C driver is included in the YugabyteDB installation. You can use it by setting the LD_LIBRARY_PATH
as follows :
$ export LD_LIBRARY_PATH=<yugabyte-install-dir>/postgres/lib
C++
libpqxx
The libpqxx driver is the official C++ client API for PostgreSQL. libpqxx
is based on libpq
and supports the SCRAM-SHA-256 authentication method.
For details and documentation, see jvt/libpqxx
README and libpqxx
ReadTheDocs.
For a tutorial on building a sample C++ application with libpqxx
, see Build a C++ application.
Install the libpqxx driver
To build and install the libpqxx driver for use with YugabyteDB, follow these steps:
- Clone the libpqxx repository.
$ git clone https://github.com/jtv/libpqxx.git
- For dependencies on the PostgreSQL binaries, add the PostgreSQL
bin
directory to the command path by running the following command.
$ export PATH=$PATH:<yugabyte-install-dir>/postgres/bin
- Build and install the driver.
$ cd libpqxx
$ ./configure
$ make
$ make install
C#
Npgsql
Npgsql is an open source ADO.NET Data Provider for PostgreSQL that enables C# applications to connect and interact with PostgreSQL databases. Npgsql is based on libpq
and supports the [SCRAM-SHA-256 authentication method.
For details on installing and using Npgsql, see Npgsql documentation.
To follow a tutorial on building a sample C# application with Npgsql, see Build a C++ application.
Install the driver
To install Npgsql in your Visual Studio project, follow the steps below.
-
Open the Project Solution View.
-
Right-click on Packages and click Add Packages.
-
Search for
Npgsql
and click Add Package.
Go
Go PostgreSQL driver (pq)
The Go PostgreSQL driver package (pq
) is a Go PostgreSQL driver for the database/sql
package. pq
is not based on the libpq
client library, but supports the SCRAM-SHA-256 authentication method.
For a tutorial on building a sample Go application with pq
, see Build a Go application.
Install the pq driver
To install the package locally, run the following go get
command:
$ go get github.com/lib/pq
The pq
driver is ready for building Go applications that connect to and interact with YugabyteDB.
Java
PostgreSQL JDBC Driver (PgJDBC)
The PostgreSQL JDBC Driver is the official JDBC driver for PostgreSQL. PgJDBC is not based on libpq
, but supports the SCRAM-SHA-256 authentication method.
For a tutorial on building a sample Go application with the PostgreSQL JDBC Driver, see Build a Java application and click YSQL-JDBC.
Install the PostgreSQL JDBC Driver
To download binary JAR files, go to PostgreSQL JDBC Driver – Downloads. Because Java is platform neutral, download the appropriate JAR file and drop it into the classpath.
To get the latest versions for projects using Apache Maven, see Maven Central Repository Search.
YugabyteDB JDBC Driver [BETA]
The YugabyteDB JDBC Driver is based on the PostgreSQL JDBC Driver (PgJDBC) and incorporates all of the functionality and behavior of that driver. The YugabyteDB JDBC driver extends PgJDBC to add support for features important for distributed SQL databases created in YugabyteDB universes: cluster awareness, connection pooling, and load balancing.
Like PgJDBC, the YugabyteDB JDBC driver is not based on libpq
, but supports the SCRAM-SHA-256 authentication method.
For details, see YugabyteDB JDBC Driver in this section.
Node.JS
node-postgres
node-postgres
is a collection of Node.js modules for interacting with PostgreSQL databases. node-postgres
optionally uses libpq
and supports the SCRAM-SHA-256 authentication method.
For details on installing and using node-postgres, see the [node-postgres documentation].
For a tutorial on building a sample Node.js application with node-postgres
, see Build a Node.js application.
Install the node-postgres (pg) driver
To install node-postgres
and any packages it depends on, run the following npm install
command:
$ npm install pg
PHP
php-pgsql
The php-pgsql
driver is a collection of the official PostgreSQL module for PHP. php-pgsql
is based on libpq
and supports the SCRAM-SHA-256 authentication method.
For a tutorial on building a sample Node.js application with php-pgsql
, see Build a Node.js application.
Install the php-pgsql driver
To enable PostgreSQL support using php-pgsql
, see [Installing/Configuring] in the PHP documentation.
Python
psycopg2
Psycopg is the popular PostgreSQL database adapter for the Python programming language. psycopg2
is based on libpq
and supports the SCRAM-SHA-256 authentication method.
For details on using psycopg2
, see Psycopg documentation.
For a tutorial on building a sample Python application that uses psycopg2
, see Build a Python application.
Install the psycopg2 binary
To install the psycopg2
binary package, run the following pip install` command:
$ pip install psycopg2
aiopg
aiopg is a library for accessing a PostgreSQL database using the asyncio (PEP
-3156/tulip) framework. It wraps
asynchronous features of the Psycopg database driver. For details on using aiopg
, see
aiopg documentation.
For a tutorial on building a sample Python application that uses psycopg2
, see Build a Python application
.
Install
To install the aio
package, run the following pip3 install
command:
pip3 install aiopg
Ruby
pg
pg
is the Ruby interface for PostgreSQL databases. pg
is based on libpq
and supports the SCRAM-SHA-256 authentication method.
For a tutorial on building a sample Ruby application with pg
, see Build a Ruby application.
Install the pg driver
To install pg
driver, run the following gem install
command:
$ gem install pg -- --with-pg-config=<yugabyte-install-dir>/postgres/bin/pg_config