Skip to main content
CockroachDB supports both native drivers and the PostgreSQL wire protocol. Most PostgreSQL client drivers and ORM frameworks work with CockroachDB.
Applications may encounter incompatibilities when using advanced or obscure features of a driver or ORM with partial support. If you encounter problems, please open an issue with details.

JavaScript/TypeScript

Drivers

pg (node-postgres)

Support level: Full The Node.js pg driver provides a simple interface for PostgreSQL-compatible databases.
npm install pg
Learn more: Build a Node.js App with CockroachDB

ORM Frameworks

Sequelize

Support level: Full Sequelize is a promise-based Node.js ORM that works with CockroachDB via a special adapter.
npm install sequelize sequelize-cockroachdb
Important: Use the sequelize-cockroachdb package to account for differences between CockroachDB and PostgreSQL.

Prisma

Support level: Full Prisma is a modern TypeScript-first ORM with excellent CockroachDB support.
npm install prisma @prisma/client
npx prisma init

TypeORM

Support level: Full
npm install typeorm pg
TypeORM provides TypeScript and JavaScript ORM capabilities. Use the cockroachdb database type in your configuration.

Knex.js

Support level: Full
npm install knex pg
Knex.js is a SQL query builder that works seamlessly with CockroachDB.

Python

Drivers

psycopg3

Support level: Full The latest version of the popular PostgreSQL adapter for Python.
pip3 install "psycopg[binary]"

psycopg2

Support level: Full The traditional PostgreSQL adapter for Python.
pip install psycopg2
For production environments, install from source. For development, you can use psycopg2-binary.

ORM Frameworks

SQLAlchemy

Support level: Full SQLAlchemy is the Python SQL toolkit and ORM. Use with the CockroachDB dialect for best results.
pip install sqlalchemy sqlalchemy-cockroachdb psycopg2
You must replace postgresql:// with cockroachdb:// in your connection string for SQLAlchemy to use the CockroachDB dialect.

Django

Support level: Full CockroachDB supports Django versions 3.1+.
pip install django==3.1.*
pip install psycopg2-binary  # or psycopg2 for production
pip install django-cockroachdb==3.1.*
The major version of django-cockroachdb must correspond to the major version of django. The minor release numbers do not need to match.

Go

Drivers

pgx

Support level: Full The pgx driver is a high-performance PostgreSQL driver for Go.
go get -u github.com/jackc/pgx/v5

pq

Support level: Full
go get -u github.com/lib/pq
A pure Go PostgreSQL driver for the database/sql package.

ORM Frameworks

GORM

Support level: Full GORM is a popular ORM library for Go.
go get -u github.com/lib/pq
go get -u gorm.io/gorm
go get -u gorm.io/driver/postgres

Java

CockroachDB requires Java 8 or higher. For production deployments, use TLS certificates for secure connections.

Drivers

JDBC

Support level: Full Download and set up the Java JDBC driver from the official PostgreSQL JDBC documentation.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

String jdbcUrl = System.getenv("JDBC_DATABASE_URL");
Connection conn = DriverManager.getConnection(jdbcUrl);

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT version()");

while (rs.next()) {
    System.out.println(rs.getString(1));
}

rs.close();
stmt.close();
conn.close();

ORM Frameworks

Hibernate

Support level: Full Hibernate versions 5.4.19 and later support the Hibernate CockroachDB dialect.
implementation 'org.hibernate:hibernate-core:6.2.0.Final'
implementation 'org.postgresql:postgresql:42.6.0'

jOOQ

Support level: Full jOOQ provides type-safe SQL queries for Java applications. Use Gradle or Maven for dependency management.

Ruby

Drivers

pg

Support level: Full
gem install pg

ORM Frameworks

Active Record

Support level: Full
gem install activerecord pg activerecord-cockroachdb-adapter
The version of activerecord-cockroachdb-adapter must match your Active Record major version (e.g., 6.0.x adapter for Active Record 6.0.x).

C# / .NET

Drivers

Npgsql

Support level: Full
dotnet new console -o cockroachdb-test-app
cd cockroachdb-test-app

Rust

Drivers

rust-postgres

Support level: Partial
Cargo.toml
[dependencies]
postgres = "0.19"
Install the Rust-Postgres driver as described in the official documentation.

Next Steps

After installing a client driver:

Connect to Database

Learn how to configure connection strings and establish connections

Use ORMs

Explore ORM frameworks and best practices

View Examples

Browse complete example applications for your language

Best Practices

Follow recommended patterns for production applications

Build docs developers (and LLMs) love