Connect to CrateDB

Connect to CrateDB using the CrateDB Npgsql Plugin.


For CrateDB versions 4.2 and above, we recommend that you use the stock Npgsql driver instead of this one.

This software is a legacy plugin for older versions of CrateDB that lacked full compatibility with Npgsql.

Table of contents


Before connecting to CrateDB, you must set up the plugin by registering a special CrateDB DatabaseInfoFactory subclass, like so:

NpgsqlDatabaseInfo.RegisterFactory(new CrateDbDatabaseInfoFactory());

The basics

Connect to CrateDB using a standard NpgsqlConnection object, like so:

var connString = "Host=;Username=crate;SSL Mode=Prefer";

using (var conn = new NpgsqlConnection(connString))

Here, we are connecting as the crate user to a CrateDB node listening on (localhost).

See also

A definitive connection string parameters reference.


The default CrateDB schema is doc, and if you do not specify a schema (using the Database connection parameter) this is what will be used.

However, once connected, you can query any schema you like by specifying it in the query.

Next steps

Use the standard Npgsql documentation for the rest of your setup process.

See also

The plugin Data types appendix.