2.1 KiB
2.1 KiB
| summary | read_when | ||
|---|---|---|---|
| TiDB tool (mysql CLI) for durable structured storage and analysis |
|
TiDB tool
Clawdbot ships a tidb tool that talks to TiDB over the MySQL protocol by invoking the local mysql CLI.
Use it when you want results to be durable and queryable (analysis, reporting, large tables), not for small ephemeral notes.
Quick setup with TiDB Cloud (recommended)
In TiDB Cloud, open your cluster Connect panel:
- Set Connect With → .env
- Copy the block like:
DB_HOST=gateway01.us-west-2.prod.aws.tidbcloud.com
DB_PORT=4000
DB_USERNAME='your.cluster.id.root'
DB_PASSWORD='<PASSWORD>'
DB_DATABASE='test'
- Paste it into the gateway host env file:
cat >> ~/.clawdbot/.env <<'EOF'
DB_HOST=gateway01.us-west-2.prod.aws.tidbcloud.com
DB_PORT=4000
DB_USERNAME='your.cluster.id.root'
DB_PASSWORD='<PASSWORD>'
DB_DATABASE='test'
EOF
- Enable the tool in
~/.clawdbot/clawdbot.json:
{
tools: {
tidb: { enabled: true }
}
}
That is it. Clawdbot will read DB_HOST/DB_PORT/DB_USERNAME/DB_PASSWORD/DB_DATABASE automatically.
Notes:
- For
*.tidbcloud.comhosts, Clawdbot defaults tomysql --ssl-mode=VERIFY_IDENTITY. - Credentials in env vars are visible to the gateway process; use a dedicated database user with minimal privileges.
Alternative: Connection string (copy, do not build by hand)
If TiDB Cloud shows a General connection string like:
mysql://your.cluster.id.root:<PASSWORD>@gateway01.us-west-2.prod.aws.tidbcloud.com:4000/test
Put it directly into ~/.clawdbot/.env as TIDB_URL:
cat >> ~/.clawdbot/.env <<'EOF'
TIDB_URL=mysql://your.cluster.id.root:<PASSWORD>@gateway01.us-west-2.prod.aws.tidbcloud.com:4000/test
EOF
Using the tool
Call the tidb tool with:
sql(required)database(optional override)format:rows(default, parses first result set) orrawtimeoutSeconds(optional)
Example:
SELECT VERSION();
See also: Env vars.