CockroachDB

Overview

Prerequisites

General
  • CockroachDB version v1.15.x or later
  • Network access allowing Zenskar to reach your CockroachDB host (for example, allow traffic across VPCs if applicable)
(Recommended) A dedicated read-only user in CockroachDB

Create a dedicated read-only user for Zenskar with access to the tables required for replication. This is optional but strongly recommended for better security, permission control, and auditing.

Run the following on your CockroachDB instance:

-- Create a dedicated Zenskar user
CREATE USER zenskar PASSWORD 'your_password_here';

-- Grant access to the required schema
GRANT USAGE ON SCHEMA <schema_name> TO zenskar;

-- Grant read-only access to all tables in the schema
GRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO zenskar;

-- Ensure future tables in the schema are also readable
ALTER DEFAULT PRIVILEGES IN SCHEMA <schema_name> GRANT SELECT ON TABLES TO zenskar;

If you need access across multiple schemas, repeat the grants for each schema.


Set up a CockroachDB data-source connector via Zenskar dashboard

Once the prerequisites are complete, connect CockroachDB as a data source in Zenskar.

  1. Log into your Zenskar dashboard.
  2. In the left side bar, click Usage > Data Sources.
  3. In the top-right corner, click + ADD DATA SOURCE.
  4. On the Add New Data Source page, configure the CockroachDB connector:
General details
FieldDescriptionRequired
Source NameEnter a unique name for this data source.Yes
Source TypeSelect CockroachDB from the dropdown menu.Yes
Connector configuration
FieldDescriptionRequired
HostThe host name or address of a CockroachDB node or load balancer.Yes
PortThe port number of the SQL interface of the CockroachDB node or load balancer. Default: 26257.Yes
DB NameThe database to use as the current database. Defaults to defaultdb when using Cockroach client commands. Drivers/ORMs may differ.Yes
UserThe database username.Yes
PasswordThe database user's password. (Avoid passing passwords directly in the URL.)Yes
JDBC URL Parameters (Advanced)Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by &. Example: key1=value1&key2=value2&key3=value3. For more information, read the JDBC URL parameters documentation.Yes
Connect using SSLSelect Yes if you need an SSL connection.Optional
Data source access mode (read-only)

Zenskar replicates data directly from your CockroachDB databse to Zenskar’s data infrastructure. The data is periodically synced to maintain freshness. This option is:

  • Ideal for small-mid size database (less than 30GB)
  • Ideal for periodical data ingestion
  • Optimised for quicker invoice generation

Addendum

Data-type mapping

CockroachDB data types are mapped to the following data types when synchronizing data:

CockroachDB typeResulting typeNotes
bigintinteger
bitboolean
booleanboolean
characterstring
character varyingstring
datestring
double precisionstring
enumnumber
inetstring
intinteger
jsonstring
jsonbstring
numericnumber
smallintinteger
textstring
time with timezonestringmay be written as a native date type depending on the destination
time without timezonestringmay be written as a native date type depending on the destination
timestamp with timezonestringmay be written as a native date type depending on the destination
timestamp without timezonestringmay be written as a native date type depending on the destination
uuidstring