Project: YugabyteDB (App Definition and Development / Database)
File: ysql-client-drivers.md

title: Client drivers for YSQL headerTitle: Client drivers for YSQL linkTitle: Client drivers for YSQL description: Lists the client drivers that you can use to connect to and interact with the YSQL API. menu: v2.18: identifier: ysql-client-libraries parent: drivers weight: 2940 type: docs The 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, refer to . 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 and support the . For help using these drivers with YSQL, ask your questions in the . If you encounter an issue or have an enhancement request, . 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 supports the . For details and documentation, refer to for PostgreSQL 11 (on which YugabyteDB is based). For a tutorial on building a sample C application with libpq, refer to . The libpq C driver is included in the YugabyteDB installation. You can use it by setting the `LDLIBRARYPATH` as follows: ```sh $ export LDLIBRARYPATH=<yugabyte-install-dir>/postgres/lib ``` Homebrew users on macOS can install libpq using `brew install libpq`. You can download the PostgreSQL binaries and source from the page. The driver is the official C++ client API for PostgreSQL. libpqxx is based on and supports the . For details and documentation, refer to the and . For a tutorial on building a sample C++ application with libpqxx, refer to . To build and install the libpqxx driver for use with YugabyteDB, first Clone the libpqxx repository. ```sh $ 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. ```sh $ export PATH=$PATH:<yugabyte-install-dir>/postgres/bin ``` Build and install the driver. ```sh $ cd libpqxx $ ./configure $ make $ make install ``` The YugabyteDB Npgsql Smart Driver is a .NET driver for YSQL built on the PostgreSQL Npgsql driver, with features that eliminate the need for external load balancers. For information on the YugabyteDB Npgsql Smart Driver and its load balancing features, see . For building a sample C# application with the YugabyteDB Npgsql driver, see . 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 and supports the . For details on Npgsql, refer to the . For building a sample C# application with Npgsql, see

To include Npgsql in your application, add the following package reference to your `.cproj` file. ```cpp <PackageReference Include="npgsql" Version="6.0.3" /> ``` If you are using Visual Studio, add Npgsql to your project as follows: Open the Project Solution View. Right-click on Packages and click Add Packages. Search for Npgsql and click Add Package. {{< warning title="Warning" >}} On every new connection, the Npgsql driver also makes , which adds significant overhead. It is recommended that you turn this behavior off to significantly reduce connection open execution time. Set the following option in your connection string builder: ```csharp connStringBuilder.ServerCompatibilityMode = ServerCompatibilityMode.NoTypeLoading; ``` Alternatively, you can add the following to your connection string: ```csharp Server Compatibility Mode=NoTypeLoading; ``` {{< /warning >}} The YugabyteDB PGX smart driver is a distributed Go driver for YSQL based on jackc/pgx, with a additional connection load balancing features. For information on the YugabyteDB PGX smart driver and its load balancing features, see . For building a sample Go application with the YugabyteDB PGX driver, see . The is a Go PostgreSQL driver for the `database/sql` package. pq is not based on , but supports the . For a tutorial on building a sample Go application with pq, see . To install the package locally, run the following command: ```sh $ go get github.com/lib/pq ``` The pq driver is ready for building Go applications that connect to and interact with YugabyteDB. The YugabyteDB JDBC Smart Driver is a distributed JDBC driver for YSQL built on the PostgreSQL JDBC driver, with features that eliminate the need for external load balancers. For information on the YugabyteDB JDBC Smart Driver and its load balancing features, see . For building a sample Java application with the YugabyteDB JDBC driver, see . The is the official JDBC driver for PostgreSQL. PgJDBC is not based on , but supports the . For building a sample Java application with the PostgreSQL JDBC driver, see . To download binary JAR files, go to . Because Java is platform neutral, download the appropriate JAR file and drop it into the classpath. To get the latest versions for projects using , see . is the client for PostgreSQL with basic APIs to communicate with the database. It is a reactive and non-blocking client for handling the database connections with a single threaded API. For a tutorial on building a sample Java application with the Vert.x PG Client, see . To get the latest versions for projects using , see . The YugabyteDB node-postgres Smart Driver is a distributed Node.js driver for YSQL built on the PostgreSQL node-postgres driver, with features that eliminate the need for external load balancers. For information on the YugabyteDB node-postgres Smart Driver and its load balancing features, see . For building a sample node.js application with the YugabyteDB node-postgres driver, see

is a collection of Node.js modules for interacting with PostgreSQL databases. node-postgres optionally uses and supports the . For details on installing and using node-postgres, see the . For a tutorial on building a Node.js application with node-postgres, see . To install node-postgres and any packages it depends on, run the following command: ```sh $ npm install pg ``` The driver is a collection of the official PostgreSQL module for PHP. php-pgsql is based on and supports the . For details on installing and using php-pgsql, see the . For a tutorial on building a sample PHP application with php-pgsql, see . To enable PostgreSQL support using php-pgsql, see in the PHP documentation. Homebrew users on macOS can install PHP using `brew install php`; the php-pgsql driver is installed automatically. Ubuntu users can install the driver using the `sudo apt-get install php-pgsql` command. CentOS users can install the driver using the `sudo yum install php-pgsql` command. The YugabyteDB Psycopg2 Smart Driver is a distributed Node.js driver for YSQL built on the PostgreSQL Psycopg2 driver, with features that eliminate the need for external load balancers. For information on the YugabyteDB Psycopg2 Smart Driver and its load balancing features, see . For building a sample Python application with the YugabyteDB Psycopg2 driver, see . is the popular PostgreSQL database adapter for the Python programming language. psycopg2 is based on and supports the . For details on using psycopg2, see . For a tutorial on building a sample Python application that uses psycopg2, see . To install the psycopg2 binary package, run the following `pip3 install` command: ```sh $ pip3 install psycopg2-binary ``` is a library for accessing a PostgreSQL database using the asyncio (PEP-3156/tulip) framework. It wraps asynchronous features of the database driver. For details on using aiopg, see . For a tutorial on building a sample Python application that uses aiopg, see . To install the aiopg package, run the following `pip3 install` command: ```sh pip3 install aiopg ``` is the Ruby interface for PostgreSQL databases. pg is based on and supports the . For a tutorial on building a sample Ruby application with pg, see . If you have installed YugabyteDB locally, run the following command to install the pg driver: ```sh $ gem install pg -- --with-pg-config=<yugabyte-install-dir>/postgres/bin/pg_config ``` Otherwise, to install pg, run the following command: ```sh gem install pg -- --with-pg-include=<path-to-libpq>/libpq/include --with-pg-lib=<path-to-libpq>/libpq/lib ``` Replace `<path-to-libpq>` with the path to the libpq installation; for example, `/usr/local/opt`. is the Rust interface for PostgreSQL databases. Rust-Postgres is not based on libpq, but supports the . For a tutorial on building a sample Ruby application with Rust-Postgres, see . To include the Rust-Postgres driver with your application, add the following dependencies to your `cargo.toml` file: ```sh postgres = "0.19.2" openssl = "0.10.38" postgres-openssl = "0.5.0" ```