Connect to CrateDB

Connect to CrateDB using the CrateDB Npgsql Plugin.

Table of Contents

Setup

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=127.0.0.1;Username=crate";

using (var conn = new NpgsqlConnection(connString))
{
    conn.Open();
}

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

See also

A definitive connection string parameters reference.

Note

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.