> ## Documentation Index
> Fetch the complete documentation index at: https://docs2.zenskar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CockroachDB

## Overview

## Prerequisites

### General

* CockroachDB version **v1.15.x or later**.
* Allow Zenskar to connect to your CockroachDB host.

### Create a dedicated read-only user in CockroachDB (recommended)

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:

```sql theme={null}
-- 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.
5. Click on the SAVE SOURCE button.

### Connector configuration

#### General configuration

| 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](https://jdbc.postgresql.org/documentation/head/connect.html) documentation. | Optional |
| **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.
* Optimized for quicker invoice generation.

***

<br />

<br />

<br />
