This is the implementation of the CockroachDB data handler for MindsDB.

CockroachDB was architected for complex, high performant distributed writes and delivers scale-out read capability. CockroachDB delivers simple relational SQL transactions and obscures complexity away from developers. It is wire-compatible with PostgreSQL and provides a familiar and easy interface for developers.

Implementation

CockroachDB is wire-compatible with PostgreSQL. Therefore, its implementation extends the PostgreSQL handler.

The required arguments to establish a connection are as follows:

  • host is the host name or IP address of the CockroachDB.
  • database is the name of the database to connect to.
  • user is the user to authenticate with the CockroachDB.
  • port is the port to use when connecting.
  • password is the password to authenticate the user.

If you installed MindsDB locally via pip, you need to install all handler dependencies manually. To do so, go to the handler’s folder (mindsdb/integrations/handlers/cockroach_handler) and run this command: pip install -r requirements.txt.

Usage

In order to make use of this handler and connect to the CockroachDB server in MindsDB, the following syntax can be used:

CREATE DATABASE cockroachdb
WITH
    engine = 'cockroachdb',
    parameters = {
        "host": "localhost",
        "database": "dbname",
        "user": "admin",
        "password": "password",
        "port": "5432"
    };

You can use this established connection to query your table as follows:

SELECT *
FROM cockroachdb.public.db;