Connect to a CrateDB cluster

This documentation section is about connecting your applications to CrateDB and CrateDB Cloud, using database drivers, and compatibility-adapters and -dialects.

Protocol Support

CrateDB supports both the HTTP protocol and the PostgreSQL wire protocol, which ensures that many clients that work with PostgreSQL, will also work with CrateDB. Through corresponding drivers, CrateDB is compatible with ODBC, JDBC, and other database API specifications.

While we generally recommend the PostgreSQL interface (PG) for maximum compatibility in PostgreSQL environments, the HTTP interface supports CrateDB bulk operations and CrateDB BLOBs, which are not supported by the PostgreSQL protocol.

The HTTP protocol can also be used to connect from environments where PostgreSQL-based communication is not applicable.

Configure

In order to connect to CrateDB, your application or driver needs to be configured with corresponding connection properties. Please note that different applications and drivers may obtain connection properties in different formats.

Connection properties

Host:

<cluster>.cratedb.net

Port:

5432 (PostgreSQL) or
4200 (HTTP)

User:

<user>

Pass:

<password>

Connection-string examples

Native PostgreSQL, psql

postgresql://<user>:<password>@<cluster>.cratedb.net:5432/doc

JDBC: PostgreSQL pgJDBC

jdbc:postgresql://<user>:<password>@<cluster>.cratedb.net:5432/doc

JDBC: CrateDB JDBC, e.g. Apache Flink

jdbc:crate://<user>:<password>@<cluster>.cratedb.net:5432/doc

HTTP: Admin UI, CLI, CrateDB drivers

https://<user>:<password>@<cluster>.cratedb.net:4200/

SQLAlchemy

crate://<user>:<password>@<cluster>.cratedb.net:4200/?schema=doc&ssl=true

Connection properties

Host:

localhost

Port:

5432 (PostgreSQL) or
4200 (HTTP)

User:

crate

Pass:

(empty)

Connection-string examples

Native PostgreSQL, psql

postgresql://crate@localhost:5432/doc

JDBC: PostgreSQL pgJDBC

jdbc:crate://crate@localhost:5432/doc

JDBC: CrateDB JDBC, e.g. Apache Flink

jdbc:crate://<user>:<password>@localhost:5432/doc

HTTP: Admin UI, CLI, CrateDB drivers

http://crate@localhost:4200/

SQLAlchemy

crate://crate@localhost:4200/?schema=doc

Tip

  • CrateDB’s fixed catalog name is crate, the default schema name is doc.

  • CrateDB does not implement the notion of a database, however tables can be created in different schemas.

  • When asked for a database name, specifying a schema name (any), or the fixed catalog name crate may be applicable.

  • If a database-/schema-name is omitted while connecting, the PostgreSQL drivers may default to the “username”.

  • The predefined superuser on an unconfigured CrateDB cluster is called crate, defined without a password.

  • For authenticating properly, please learn about the available authentication options.

Client Libraries

This section lists drivers and adapters for relevant programming languages, frameworks, and environments.

PostgreSQL

The drivers listed in this section all use the CrateDB PostgreSQL interface.

Driver/Adapter

Description

Info

-

The official PostgreSQL ODBC Driver. For connecting to CrateDB from any environment that supports it.

.NET

An open source ADO.NET Data Provider for PostgreSQL, for program written in C#, Visual Basic, and F#.

.NET

This fork of the official driver was needed prior to CrateDB 4.2.

Golang

pgx

A pure Go driver and toolkit for PostgreSQL.

Java

The official PostgreSQL JDBC Driver. For connecting to CrateDB from any environment that supports it.

Java

For connecting to CrateDB with specialized type system support and other tweaks. Ignores the ROLLBACK statement and the hstore and jsonb extensions.

Node.js

A collection of Node.js modules for interfacing with a PostgreSQL database using JavaScript or TypeScript.

Has support for callbacks, promises, async/await, connection pooling, prepared statements, cursors, streaming results, C/C++ bindings, rich type parsing, and more.

PHP

For connecting to CrateDB from PHP, supporting its PDO interface.

PHP

For connecting to CrateDB using AMPHP, an Async PostgreSQL client for PHP. AMPHP is a collection of high-quality, event-driven libraries for PHP designed with fibers and concurrency in mind.

Python

For connecting to CrateDB from Python, supporting Python’s asyncio (PEP-3156/tulip) framework.

Python

For connecting to CrateDB from Python, supporting Python’s asyncio.

Python

For connecting to CrateDB from Python, supporting Python’s asyncio.

HTTP

The drivers listed in this section all use the CrateDB HTTP interface.

Driver/Adapter

Description

Info

MicroPython

A MicroPython library connecting to the CrateDB HTTP API.

Node.js

A JavaScript library connecting to the CrateDB HTTP API.

PHP

For connecting to CrateDB from PHP.

PHP

For connecting to CrateDB from PHP, using DBAL and Doctrine.

Python

For connecting to CrateDB from Python. Has support for CrateDB BLOBs.

Python

For connecting to CrateDB from Python, using SQLAlchemy.

Ruby

A Ruby client library for CrateDB.

Ruby

Ruby on Rails ActiveRecord adapter for CrateDB.

Tip

Please visit the Build Status page for an overview about the integration status of the client drivers listed above, and more.