Python

Connect to CrateDB and CrateDB Cloud from Python.

Individual adapters, clients, and drivers offer specific features for specific needs of your application, so please read this enumeration carefully, to select the optimal adapter client or driver for your purposes.

As a general recommendation, using the SQLAlchemy adapter for many reasons isn’t a bad choice, because many other frameworks will use it anyway. A good example is the most high-level Python package records.

Other than this, we can recommend psycopg3 and asyncpg if you are looking at using the PostgreSQL protocol.

Official clients

Standard

Standard clients implementing the Python DB API and the CrateDB dialect for SQLAlchemy. crate-python uses urllib3. sqlalchemy-cratedb uses crate-python.

Special purpose

Adapter clients and drivers for special requirements on the environment or on performance details. conecta uses Rust and Apache Arrow. cratedb-async uses httpx. micropython-cratedb uses MicroPython’s standard httplib.

Tertiary clients

Clients that either use the PostgreSQL wire protocol, or standard interfaces like SQLAlchemy. psycopg2 and psycopg3 use libpq. aiopg uses psycopg2. connectorx uses Rust. records uses sqlalchemy, so it also uses sqlalchemy-cratedb. turbodbc uses PostgreSQL ODBC.

Dataframe libraries

Use CrateDB together with popular open-source dataframe libraries. Each of them is using the CrateDB SQLAlchemy dialect for database communications.

Tip

The insert_bulk utility function from sqlalchemy-cratedb unlocks a performance path, see also Bulk Support for pandas and Dask. About optimally configuring pandas and Dask for efficient insert operations, see also DataFrame operations.