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.
- Log into your Zenskar dashboard.
- In the left side bar, click Usage > Data Sources.
- In the top-right corner, click + ADD DATA SOURCE.
- On the Add New Data Source page, configure the CockroachDB connector:
General details
| Field | Description | Required |
|---|---|---|
| Source Name | Enter a unique name for this data source. | Yes |
| Source Type | Select CockroachDB from the dropdown menu. | Yes |
Connector configuration
| Field | Description | Required |
|---|---|---|
| Host | The host name or address of a CockroachDB node or load balancer. | Yes |
| Port | The port number of the SQL interface of the CockroachDB node or load balancer. Default: 26257. | Yes |
| DB Name | The database to use as the current database. Defaults to defaultdb when using Cockroach client commands. Drivers/ORMs may differ. | Yes |
| User | The database username. | Yes |
| Password | The 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 SSL | Select 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 type | Resulting type | Notes |
|---|---|---|
bigint | integer | |
bit | boolean | |
boolean | boolean | |
character | string | |
character varying | string | |
date | string | |
double precision | string | |
enum | number | |
inet | string | |
int | integer | |
json | string | |
jsonb | string | |
numeric | number | |
smallint | integer | |
text | string | |
time with timezone | string | may be written as a native date type depending on the destination |
time without timezone | string | may be written as a native date type depending on the destination |
timestamp with timezone | string | may be written as a native date type depending on the destination |
timestamp without timezone | string | may be written as a native date type depending on the destination |
uuid | string |
Updated 1 day ago
