CockroachDB dialect for SQLAlchemy
For psycopg2 support you must install either:
psycopg2, which has some prerequisites of its own.
(The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.)
Or, for asyncpg support (⚠️ experimental 🏗) you must install
Use pip
to install the latest version.
pip install sqlalchemy-cockroachdb
NOTE: This version of the dialect requires SQLAlchemy 2.0 or later. To work with earlier versions of SQLAlchemy you'll need to install an earlier version of this dialect.
pip install sqlalchemy-cockroachdb<2.0.0
Use a cockroachdb
connection string when creating the Engine
. For example,
to connect to an insecure, local CockroachDB cluster using psycopg2:
from sqlalchemy import create_engine
engine = create_engine('cockroachdb://root@localhost:26257/defaultdb?sslmode=disable')
or
from sqlalchemy import create_engine
engine = create_engine('cockroachdb+psycopg2://root@localhost:26257/defaultdb?sslmode=disable')
To connect using asyncpg (⚠️ experimental 🏗):
from sqlalchemy import create_async_engine
engine = create_async_engine('cockroachdb+asyncpg://root@localhost:26257/defaultdb')
See CHANGES.md