Prerequisites
- A CockroachDB cluster whose SQL endpoint CloudThinker can reach from the internet. Agents connect from CloudThinker Cloud, so
localhostand private addresses resolve there, not on your network. See Reaching private services. - An admin account that can create SQL users and grant privileges.
- Password authentication with TLS. The connection rejects
sslmode=disable,allow, andprefer.
Setup
1
Create two SQL users
Open a SQL session as an admin, either from the SQL Shell in the CockroachDB Cloud console or with
cockroach sql --url '<admin-connection-string>'. Then create one user for reads and one for approved writes:2
Grant table privileges
Run these in each schema agents should reach. This example uses The write user needs You can’t skip the write user, because the form requires it. If you want reads only, create the write user and give it no table privileges. Every approved write then fails at the database.
public:SELECT too: CockroachDB requires it for any UPDATE or DELETE that reads rows through a WHERE clause, and agents always send one.Tables created later need the same grants. To cover them automatically, set default privileges for the role that creates your tables (app_owner here):3
Let the read user see running statements (optional)
Grant
VIEWACTIVITY only if agents should see statements from other sessions. Schema and data reads work without it. Statement text includes literal values, which can hold personal data, so leave it off if that matters to you.4
Open network access
CloudThinker must reach the SQL port (default
26257). In CockroachDB Cloud, open your cluster’s Networking page and add CloudThinker’s egress IPs to the IP Allowlist. For a self-hosted cluster, allow them in your firewall or security group. These docs don’t publish CloudThinker’s egress IP list: ask your CloudThinker contact, or contact us.5
Build two connection strings
Make one string per user, both pointing at the same cluster and database. URL-encode special characters in each password.
- CockroachDB Cloud
- Self-hosted
Open your cluster’s Connect dialog and copy the general connection string, then swap in each user:Remove any
sslrootcert path that points at a file on your own machine, since CloudThinker can’t read it.6
Add the connection in CloudThinker
Open More → Workspace settings → Connections, select CockroachDB, and click Connect on its detail panel. In the dialog, optionally change the Alias and Description. Paste the read URL into Connection string and the write URL into Write connection string, then click Connect.Success state: the connection shows Connecting and Verifying, then Connected. CloudThinker then runs Discovery once, and its results show in the Discovery section of the connection’s detail panel.
Connection details
The two strings must differ. If they’re identical, or the write string is empty, CloudThinker won’t run the connection.
Required permissions
Agent capabilities
Queries stop after 30 seconds and return at most 1,000 rows.
EXPLAIN ANALYZE is refused because it runs the statement. Node inventory and the SQL user list aren’t available: CockroachDB v26 restricts the internal tables that hold them, and agents say so instead of guessing.
Verify the connection
relation does not exist error means the name was wrong or the read user can’t see it.
Example prompts
Write access
Agents can only insert, update, or delete rows. Each change goes through Approvals and runs with the write connection string for that one call. Every change an agent makes goes through your workspace’s Approvals first. On the default Auto · Rules + AI · Ask me mode, AI judgment can let a safe change run without asking — and an Allow Rule can too, once CloudThinker turns on Rule enforcement for your workspace. Choose Manual to approve every change yourself.- Before asking, the agent names the action, the table, and the
WHEREclause that selects the rows. - An
UPDATEorDELETEwithout aWHEREclause is refused. - Agents can’t create, alter, drop, or truncate databases, tables, or indexes.
- The result reports the action, table, and number of affected rows, never the row values.
- Approving one change doesn’t approve the next.
Troubleshooting
The SSL mode is rejected
The SSL mode is rejected
Use
sslmode=require, verify-ca, or verify-full. The connection refuses disable, allow, and prefer because they allow an unencrypted connection.Authentication or connection fails
Authentication or connection fails
Check the username, URL-encoded password, host, port (default
26257), and database in each string. After a password reset, copy the connection string again from the CockroachDB Cloud console.A table is missing or a query is denied
A table is missing or a query is denied
The read user lacks
USAGE on the schema or SELECT on the table. New tables need their own grants or default privileges.A write is refused
A write is refused
Confirm the write URL differs from the read URL, the write user holds the privilege for that table (plus
SELECT for an update or delete), and this specific change was approved. Every update or delete needs a WHERE clause.LIMIT exceeds maximum
LIMIT exceeds maximum
A query asked for more than 1,000 rows. Ask for a smaller set, or a count or aggregate filtered on the server.
Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Separate users for reads and writes: keep the read user to
SELECTonly, and give row-change privileges to the write user alone. Never give the read userINSERT,UPDATE, orDELETE. - Verify the server certificate: prefer
sslmode=verify-fullwhen the cluster’s certificate comes from a public CA and its hostname matches. Userequirefor a private CA.
Related
PostgreSQL
Connect a PostgreSQL database with a read-only user.
Approvals
Decide which row changes run, wait for a person, or are refused.