> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Install a Driver or ORM Framework

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

CockroachDB supports both native drivers and the PostgreSQL wire protocol, so most available PostgreSQL client drivers and ORM frameworks should work with CockroachDB.

Choose a language for supported clients, and follow the installation steps. After you install a client library, you can <InternalLink path="connect-to-the-database">connect to the database</InternalLink>.

<Note>
  Applications may encounter incompatibilities when using advanced or obscure features of a driver or ORM framework with **partial** support. If you encounter problems, please <InternalLink path="support-resources">contact Support</InternalLink>.
</Note>

<AccordionGroup>
  <Accordion title="JavaScript/TypeScript" description="View support and resources for pg, Sequelize, Knex.js, TypeORM, or Prisma">
    ## JavaScript Drivers

    ### pg

    **Support level:** Full

    To install the <a href="https://www.npmjs.com/package/pg">Node.js pg driver</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ npm install pg
    ```

    For a simple but complete example app, see <InternalLink path="build-a-nodejs-app-with-cockroachdb">Build a Node.js App with CockroachDB and the Node.js pg Driver</InternalLink>.

    ## JavaScript/TypeScript ORM frameworks

    ### Sequelize

    **Support level:** Full

    To install Sequelize and a <a href="https://github.com/cockroachdb/sequelize-cockroachdb">CockroachDB Node.js package</a> that accounts for some minor differences between CockroachDB and PostgreSQL:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ npm install sequelize sequelize-cockroachdb
    ```

    For a simple but complete example app, see <InternalLink path="build-a-nodejs-app-with-cockroachdb-sequelize">Build a Node.js App with CockroachDB and Sequelize</InternalLink>.

    ### Knex.js

    **Support level:** Full

    Install Knex.js as described in the <a href="https://knexjs.org/#Installation">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-nodejs-app-with-cockroachdb-knexjs">Build a Simple CRUD Node.js App with CockroachDB and Knex.js</InternalLink>.

    ### TypeORM

    **Support level:** Full

    Install TypeORM as described in the <a href="https://typeorm.io/#/">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-typescript-app-with-cockroachdb">Build a TypeScript App with CockroachDB and TypeORM</InternalLink>.

    ### Prisma

    **Support level:** Full

    To install the <a href="https://prisma.io/">Prisma ORM</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ npm install prisma
    ```

    For a simple but complete example app, see <InternalLink path="build-a-nodejs-app-with-cockroachdb-prisma">Build a Simple CRUD Node.js App with CockroachDB and Prisma</InternalLink>.
  </Accordion>

  <Accordion title="Python" description="View support and resources for psycopg3, psycopg2, SQLAlchemy, Django, or peewee">
    ## Python Drivers

    ### psycopg3

    **Support level:** Full

    To install the Python psycopg3 driver:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip3 install "psycopg[binary]"
    ```

    For other ways to install psycopg3, see the <a href="https://www.psycopg.org/psycopg3/docs/basic/install">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-python-app-with-cockroachdb-psycopg3">Build a Python App with CockroachDB and psycopg3</InternalLink>.

    ### psycopg2

    **Support level:** Full

    To install the Python psycopg2 driver:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip install psycopg2
    ```

    For other ways to install psycopg2, see the <a href="http://initd.org/psycopg/docs/install">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-python-app-with-cockroachdb">Build a Python App with CockroachDB and psycopg2</InternalLink>.

    ## Python ORM frameworks

    ### SQLAlchemy

    **Support level:** Full

    To install SQLAlchemy and a <a href="https://github.com/cockroachdb/sqlalchemy-cockroachdb">CockroachDB Python package</a> that accounts for some differences between CockroachDB and PostgreSQL:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip install sqlalchemy sqlalchemy-cockroachdb psycopg2
    ```

    <Tip>
      You can substitute psycopg2 for other alternatives that include the psycopg python package.
    </Tip>

    For other ways to install SQLAlchemy, see the <a href="http://docs.sqlalchemy.org/intro#installation-guide">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-python-app-with-cockroachdb-sqlalchemy">Build a Python App with CockroachDB and SQLAlchemy</InternalLink>.

    ### Django

    **Support level:** Full

    CockroachDB supports Django versions 3.1+.

    To install <a href="https://docs.djangoproject.com/en/4.0/topics/install">Django</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip install django==3.1.*
    ```

    Before installing the <a href="https://github.com/cockroachdb/django-cockroachdb">CockroachDB backend for Django</a>, you must install one of the following psycopg2 prerequisites:

    * <a href="https://pypi.org/project/psycopg2">psycopg2</a>, which has some <a href="https://www.psycopg.org/docs/install#prerequisites">prerequisites</a> of its own. This package is recommended for production environments.
    * <a href="https://pypi.org/project/psycopg2-binary">psycopg2-binary</a>. This package is recommended for development and testing.

    After you install the psycopg2 prerequisite, you can install the CockroachDB Django backend:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip install django-cockroachdb==3.1.*
    ```

    <Note>
      The major version of `django-cockroachdb` must correspond to the major version of `django`. The minor release numbers do not need to match.
    </Note>

    For a simple but complete example app, see <InternalLink path="build-a-python-app-with-cockroachdb-django">Build a Python App with CockroachDB and Django</InternalLink>.

    ### peewee

    **Support level:** Full

    To install peewee:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ pip install peewee
    ```

    For instructions on using peewee with CockroachDB, see the <a href="http://docs.peewee-orm.com/en/latest/peewee/playhouse#cockroach-database">CockroachDatabase peewee extension documentation</a>.
  </Accordion>

  <Accordion title="Go" description="View support and resources for pgx, pq, or GORM">
    ## Go Drivers

    ### pgx

    **Support level:** Full

    To install the <a href="https://pkg.go.dev/github.com/jackc/pgx">Go pgx driver</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ go get -u github.com/jackc/pgx
    ```

    For a simple but complete example app, see <InternalLink path="build-a-go-app-with-cockroachdb">Build a Go App with CockroachDB and the Go pgx Driver</InternalLink>.

    ### pq

    **Support level:** Full

    To install the <a href="https://godoc.org/github.com/lib/pq">Go pq driver</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ go get -u github.com/lib/pq
    ```

    For a simple but complete example app, see <InternalLink path="build-a-go-app-with-cockroachdb">Build a Go App with CockroachDB and the Go pq Driver</InternalLink>.

    ## Go ORM frameworks

    ### GORM

    **Support level:** Full

    To install <a href="http://gorm.io/">GORM</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ go get -u github.com/lib/pq # dependency
    ```

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ go get -u github.com/jinzhu/gorm
    ```

    For a simple but complete example app, see <InternalLink path="build-a-go-app-with-cockroachdb-gorm">Build a Go App with CockroachDB and GORM</InternalLink>.
  </Accordion>

  <Accordion title="Java" description="View support and resources for JDBC, Hibernate, or jOOQ">
    <Note>
      We recommend using Java versions 8+ with CockroachDB.
    </Note>

    CockroachDB supports TLS 1.2 and 1.3, and uses 1.3 by default.

    CockroachDB supports the <a href="https://wikipedia.org/wiki/Transport_Layer_Security">TLS 1.3 and TLS 1.2</a> encryption for SQL clients. Only cipher suites currently recommended by the IETF (<a href="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4">RFC 8447</a>) are enabled by default. The environment variable `COCKROACH_TLS_ENABLE_OLD_CIPHER_SUITES` can be used to revert to the cipher suite configuration used prior to v22.2. You should set this environment variable only if you cannot use one of the default cipher suites, but you can use one of the disabled ones.

    SQL clients, intermediate proxies, or load balancers that do not support any cipher suites that CockroachDB supports will be unable to connect to CockroachDB clusters. For the full list of supported cipher suites, refer to <a href="https://cockroachlabs.com/docs/stable/authentication#supported-cipher-suites">Supported cipher suites</a>.
    <a href="https://bugs.openjdk.java.net/browse/JDK-8236039">A bug in the TLS 1.3 implementation</a> in Java 11 versions lower than 11.0.7 and Java 13 versions lower than 13.0.3 makes the versions incompatible with CockroachDB.

    If an incompatible version is used, the client may throw the following exception:

    `javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request`

    For applications running Java 11 or 13, make sure that you have version 11.0.7 or higher, or 13.0.3 or higher.

    If you cannot upgrade to a version higher than 11.0.7 or 13.0.3, you must configure the application to use TLS 1.2. For example, when starting your app, use: `$ java -Djdk.tls.client.protocols=TLSv1.2 appName`

    ## Java Drivers

    ### JDBC

    **Support level:** Full

    Download and set up the latest Java JDBC driver as described in the <a href="https://jdbc.postgresql.org/documentation/setup">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-java-app-with-cockroachdb">Build a Java App with CockroachDB and JDBC</InternalLink>.

    ## Java ORM frameworks

    ### Hibernate

    **Support level:** Full

    You can use <a href="https://gradle.org/install">Gradle</a> or <a href="https://maven.apache.org/install">Maven</a> to get all dependencies for your application, including Hibernate. Only Hibernate versions 5.4.19 and later support the Hibernate CockroachDB dialect.

    If you are using Gradle, add the following to your `dependencies`:

    ```groovy theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    implementation 'org.hibernate:hibernate-core:{version}.Final'
    implementation 'org.postgresql:postgresql:{version}'
    ```

    Where <code>{'{version}'}</code> is the latest stable version.

    For a simple but complete example app that uses Gradle for dependency management, see <InternalLink path="build-a-java-app-with-cockroachdb-hibernate">Build a Java App with CockroachDB and Hibernate</InternalLink>.

    If you are using Maven, add the following to your `<dependencies`:

    ```xml theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    <dependency>
        <groupId>org.hibernate</groupId
        <artifactId>hibernate-core</artifactId
        <version>{version}.Final</version
    </dependency
    <dependency>
        <groupId>org.postgresql</groupId
        <artifactId>postgresql</artifactId
    </dependency
    ```

    Where <code>{'{version}'}</code> is the latest stable version.

    You will also need to specify the CockroachDB dialect in your <a href="https://www.tutorialspoint.com/hibernate/hibernate_configuration.htm">Hibernate configuration file</a>.

    Versions of the Hibernate CockroachDB dialect correspond to the version of CockroachDB installed on your machine. For example, `org.hibernate.dialect.CockroachDB201Dialect` corresponds to CockroachDB v20.1 and later, and `org.hibernate.dialect.CockroachDB192Dialect` corresponds to CockroachDB v19.2 and later.

    All dialect versions are forward-compatible (e.g., CockroachDB v20.1 is compatible with `CockroachDB192Dialect`), as long as your application is not affected by any backward-incompatible changes listed in your CockroachDB version's <InternalLink version="releases" path="index">dialect</InternalLink>. In the event of a CockroachDB version upgrade, using a previous version of the CockroachDB dialect will not break an application, but, to enable all features available in your version of CockroachDB, we recommend keeping the dialect version in sync with the installed version of CockroachDB.

    Not all versions of CockroachDB have a corresponding dialect yet. Use the dialect number that is closest to your installed version of CockroachDB. For example, use `CockroachDB201Dialect` when using CockroachDB v21.1 and later.

    ### jOOQ

    **Support level:** Full

    You can use <a href="https://gradle.org/install">Gradle</a> or <a href="https://maven.apache.org/install">Maven</a> to get all dependencies for your application, including jOOQ.

    For a simple but complete example app that uses Maven for dependency management, see <InternalLink path="build-a-java-app-with-cockroachdb-jooq">Build a Java App with CockroachDB and jOOQ</InternalLink>.
  </Accordion>

  <Accordion title="Ruby" description="View support and resources for pg or Active Record">
    ## Ruby Drivers

    ### pg

    **Support level:** Full

    To install the <a href="https://rubygems.org/gems/pg">Ruby pg driver</a>:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ gem install pg
    ```

    For a simple but complete example app, see <InternalLink path="build-a-ruby-app-with-cockroachdb">Build a Ruby App with CockroachDB and the Ruby pg Driver</InternalLink>.

    ## Ruby ORM frameworks

    ### Active Record

    **Support level:** Full

    To install Active Record, the <a href="https://rubygems.org/gems/pg">pg driver</a>, and a <a href="https://github.com/cockroachdb/activerecord-cockroachdb-adapter">CockroachDB Ruby package</a> that accounts for some minor differences between CockroachDB and PostgreSQL:

    ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
    $ gem install activerecord pg activerecord-cockroachdb-adapter
    ```

    <Note>
      The exact command above will vary depending on the desired version of Active Record. Specifically, version 6.0.x of Active Record requires version 6.0.x of the adapter and version 7.0.x of Active Record requires version 7.0.x of the adapter.
    </Note>

    For a simple but complete example app, see <InternalLink path="build-a-ruby-app-with-cockroachdb-activerecord">Build a Ruby App with CockroachDB and Active Record</InternalLink>.
  </Accordion>

  <Accordion title="C" description="View support and resources for libpq">
    ## C Drivers

    ### libpq

    **Support level:** Partial

    Install the C libpq driver as described in the <a href="https://www.postgresql.org/docs/current/libpq">official documentation</a>.
  </Accordion>

  <Accordion title="C# (.NET)" description="View support and resources for Npgsql">
    ## C# Drivers

    ### Npgsql

    **Support level:** Full

    1. Create a.NET project:

       ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
       $ dotnet new console -o cockroachdb-test-app
       ```

       ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
       $ cd cockroachdb-test-app
       ```

       The `dotnet` command creates a new app of type `console`. The `-o` parameter creates a directory named `cockroachdb-test-app` where your app will be stored and populates it with the required files. The `cd cockroachdb-test-app` command puts you into the newly created app directory.
    2. Install the latest version of the <a href="https://www.nuget.org/packages/Npgsql">Npgsql driver</a> into the.NET project using the built-in nuget package manager:

       ```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
       $ dotnet add package Npgsql
       ```

    For a simple but complete example app, see <InternalLink path="build-a-csharp-app-with-cockroachdb">Build a C# App with CockroachDB and the.NET Npgsql Driver</InternalLink>.
  </Accordion>

  <Accordion title="Rust" description="View support and resources for rust-postgres">
    ## Rust Drivers

    ### rust-postgres

    **Support level:** Partial

    Install the Rust-Postgres driver as described in the <a href="https://crates.io/crates/postgres">official documentation</a>.

    For a simple but complete example app, see <InternalLink path="build-a-rust-app-with-cockroachdb">Build a Rust App with CockroachDB and the Rust-Postgres Driver</InternalLink>.
  </Accordion>
</AccordionGroup>

## What's next?

* <InternalLink path="connect-to-the-database">Connect to CockroachDB</InternalLink>
* <InternalLink path="schema-design-overview">Design a Database Schema</InternalLink>

You might also be interested in the following pages:

* <InternalLink path="third-party-database-tools">Third party database tools</InternalLink>
* <InternalLink path="connection-parameters">Connection parameters</InternalLink>
* <InternalLink path="transactions">Transactions</InternalLink>
* <InternalLink path="performance-best-practices-overview">Performance best practices</InternalLink>
