Intro
Imagine you’re running a real production system — real users, real payments, real consequences.
And you want to ask AI:
- “How many users signed up this week?”
- “What’s our average order value?”
- “Why did this order fail?”
Sounds easy… until you realize the risk.
The Problem
Letting AI directly access your production database is a bad idea.
Not “maybe risky.” Just bad.
Because:
- It could run destructive queries (
DROP TABLE users) - It could expose sensitive data (emails, passwords, payment info)
- It could run heavy queries that slow down your app for real users
Giving an AI direct DB access is like handing a stranger the keys to your bank vault.
The Solution: A Safe Sandbox
AskDB solves this by creating a sandboxed copy of your database.
You can check out the project here:
👉 https://github.com/mgorabbani/askdb
Here’s how it works:
Production Database (live system)
│
│ dump (pg_dump / mongodump)
▼
Sandbox Database (Docker container)
│
│ AI queries happen here
▼
ChatGPT / Claude / Cursor
The sandbox is completely isolated.
The AI can:
- Run queries
- Make mistakes
- Even delete data
And none of it touches production.
Think of it like a photocopy of your vault — safe to explore without risk.
“Why Not Just Use a Read-Only Database User?”
A natural question is:
“Why not just use a read-only database user and call it a day?”
That does help — it prevents writes.
But it doesn’t solve the full problem.
A read-only user can still access everything:
- Emails
- Password hashes
- Phone numbers
- Internal business data
Now imagine that data flowing through an AI tool.
Even if nothing is modified, you still risk:
- Sensitive data appearing in AI responses
- Data being stored in chat history or logs
- Team members seeing data they shouldn’t
So the problem isn’t just writes — it’s also what the AI is allowed to read.
AskDB adds a layer of control:
- Hide specific fields (
email,password, etc.) - Limit what AI can access
- Share safely with your team
Real Use Cases
Once you have a safe sandbox, things get powerful:
- Analyze churn
“How many users churned last month?”
- Revenue insights
“Top 10 products by revenue”
- Debugging
“Why did this order fail?”
All answered without risking your live system.
Why Sync Matters
There’s one catch.
Your sandbox is a snapshot in time.
Meanwhile, production keeps changing:
- New users sign up
- Orders come in
- Data evolves
If your snapshot is old, your insights are wrong.
Right now, AskDB refreshes the sandbox once a day.
That works — but for fast-moving systems, it’s not always enough.
The Big Idea
AskDB lets you safely combine:
- Real production data
- AI-powered analysis
Without risking your system, your users, or your sanity.
What I’m Working On
One limitation of this approach is data freshness.
If the sandbox isn’t updated frequently, the insights can become outdated.
I’m currently working on adding configurable auto-sync, so the sandbox stays fresh without touching production.
I wrote about it in Making AskDB Data Fresher: Adding Auto-Sync.
Top comments (0)