dbtrail
Claude Integration

Using Claude with dbtrail

Query your MySQL change history using natural language

Once you've connected Claude to dbtrail, you can query your MySQL change history using natural language.

Example conversations

Finding deleted rows

You: Show me all rows deleted from the orders table in production in the last 24 hours.

Claude: I found 3 deleted rows in production.orders since yesterday:

order_idcustomeramountdeleted_at
1042acme-corp$299.002026-03-07 14:23:01
1043widgets-inc$150.502026-03-07 15:01:33
1044acme-corp$75.002026-03-07 16:45:12

Investigating changes

You: What changed in the users table for user_id 5678 this week?

Claude: I found 2 changes to user 5678 this week:

  1. UPDATE on Mar 5 at 10:15 — email changed from old@example.com to new@example.com
  2. UPDATE on Mar 7 at 09:30 — status changed from active to suspended

Counting events by table

You: How many INSERTs happened across all tables in the last hour?

Claude: Here's the INSERT activity in the last hour, broken down by table:

SchemaTableCount
demometrics12,440
demoorder_items8,910
demoaudit_log4,823
demoorders3,022
democustomers1,580

Total: 30,775 INSERTs across 5 tables in the last hour. The metrics table accounts for 40% of all INSERT volume.

Finding the busiest tables

You: Which table had the most DELETEs today?

Claude: I checked DELETE activity across all tables today. The session_tokens table had by far the most DELETEs — 45,230 — likely from automatic session cleanup. The next highest was temp_results with 2,100.

Finding the first event of the day

You: What is the oldest registered event that happened today on the production server?

Claude: The earliest event today was an INSERT into production.heartbeat at 2026-03-20 00:00:01 UTC — a routine heartbeat write from the replication monitor.

Tracking who changed a row first

You: Who was the first person to modify the pricing table in ecommerce since Monday?

Claude: Using forensic enrichment, the first change was an UPDATE at 2026-03-17 08:12:44 UTC by deploy_bot@10.0.3.22 (via mysql-connector-python). It changed the discount_pct column on product_id 891 from 0.10 to 0.15.

Finding the earliest delete in a time range

You: Show me the first row deleted from sessions after the deploy at 2pm yesterday.

Claude: The first DELETE in app.sessions after 2026-03-19 14:00 was at 14:03:22 UTC:

session_iduser_idcreated_atdeleted_at
a8f3c9e120412026-03-19 09:15:002026-03-19 14:03:22

This was 3 minutes after the deploy — could be the new session cleanup job kicking in.

Generating recovery SQL

You: Generate SQL to recover the deleted order 1042.

Claude: Here's the recovery SQL (dry-run). Review carefully before executing:

SET autocommit = 0;
BEGIN;
INSERT INTO `production`.`orders` (`order_id`, `customer`, `amount`, `status`)
VALUES (1042, 'acme-corp', 299.00, 'active');
COMMIT;

Always review recovery SQL

Recovery is always dry-run — Claude generates the SQL but never executes it. A DBA must review and run the SQL manually.

Tips for effective queries

  1. Be specific about the server — if you have multiple servers, mention which one: "on the production-main server"
  2. Use time ranges — "in the last hour", "since March 1st", "between 2pm and 3pm yesterday"
  3. Filter by event type — "show me only DELETEs", "what was updated"
  4. Reference tables explicitly — "in the orders table in the mydb schema"
  5. Ask volume questions — "how many writes happened today?" or "which table is busiest?" — Claude will use the efficient count_events tool instead of fetching individual rows
  6. Ask for the first or oldest event — "what was the first INSERT today?", "show me the oldest delete since the deploy" — Claude can use order: ASC to retrieve the oldest events first without scanning through all results

What Claude can and cannot do

Can doCannot do
Query indexed changesExecute SQL on your database
Count events with groupingModify data directly
Filter by schema, table, time, event typeRun recovery SQL automatically
Generate recovery SQL (dry-run)Start/stop streams
Check server and stream statusAccess data outside your tenant
Answer volume and trend questions

Rate limits

Requests from AI assistants are subject to the same rate limits as API requests. See Authentication for details.

On this page