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

<clustername>.cratedb.net

Port

5432 (PostgreSQL) or 4200 (HTTP)

User

<username>

Pass

<password>

Connection-string examples

A native PostgreSQL connection string. postgresql://<username>@<clustername>.cratedb.net/crate

A connection string for SQLAlchemy or Apache Flink. crate://<username>@<clustername>.cratedb.net/crate

An HTTP URL to visit Admin UI. https://<username>@<clustername>.cratedb.net:4200/

Connection properties

Host

localhost

Port

5432 (PostgreSQL) or 4200 (HTTP)

User

crate

Pass

(empty)

Connection-string examples

A native PostgreSQL connection string. postgresql://crate@localhost:5432/crate

A connection string for SQLAlchemy or Apache Flink. crate://crate@localhost/crate

An HTTP URL to visit Admin UI. http://crate@localhost:4200/

Tip

  • Specify the schema name doc, if you are asked for a database name.

  • The default superuser on a vanilla CrateDB cluster is called crate, without a password.

  • When aiming to authenticate 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

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.