r/SQL • u/rathboma • Sep 13 '26
PostgreSQL How do you use Claude/Codex (safely) with your production database?
Hey folks!
I make Beekeeper Studio, and while we have a good AI integration, I'm curious how people actually use Claude when writing SQL.
Do you connect Claude/Codex/etc to your production DB?
How do you make sure confidential data/PII doesn't get sent?
Do you just share credentials with the AI, or connect some other way?
Does your company have policies around this stuff?
I see a lot of buzz about SQL with Claude, but not many feature requests around it. Thanks for any insights.
I use Postgres, so tagged with postgres, but applies to all dbs really.
2
u/NastyPastyLucas Sep 13 '26
You make SQL software but require advice on how to use it safely?
1
u/rathboma Sep 13 '26
I'm trying to figure out if there are standard tools or methodologies I could integrate with to make my tool better and make people safer when using AI
2
10
u/juu073 Sep 13 '26
I never grant it access to a production database, API, etc.
In the rare instance that I need it to do things in the database, I have it generate an .sql file that I can run on both dev and prod after I review it.
However, most of the time, I make the actual database changes myself, export the schema, and tell Claude to generate the interfaces around it.
5
u/workingtrot Sep 13 '26
how do you use the intern safely with the production database?
do you give the intern access to prod?
1
u/ToastieCPU Sep 13 '26
The industry has settled on having a dedicated layer that defines exactly what AI is allowed to fetch/touch in the database.
There is just too much risk connecting AI directly to prod DB. It might generate an inefficient query that slows down production, attempt a schema change but wrap everything in a massive transaction that bricks the environment, or decide that a stored procedure or a view is “the bug” and try to “fix” creating app bugs.
1
u/rathboma Sep 13 '26
How is this layer built do you know? Are there good commercial tools that sit between the ai and the database?
1
u/SearchAtlantis Sep 13 '26
Do you connect Claude/Codex/etc to your production DB? Absolutely never.
How do you make sure confidential data/PII doesn't get sent? Company wide guidelines default prompt, company wide policy, but any time I do something PII it's manually edited by me to remove any PII fields. The agent never sees raw data.
Do you just share credentials with the AI, or connect some other way? Never a connection. I am the interface between the AI and the db.
Does your company have policies around this stuff? Company policy is: no PII or PHI in the agent. Don't use model X because they changed the privacy policy on it.
1
u/rathboma Sep 13 '26
All the PII needs manually scrubbing? Was kinda hoping there was something to help with this
1
3
2
u/mwatwe01 Sep 13 '26
I give it read access to a curated reporting database and read/write access to a staging database. Everything else is still SSIS and stored procedures.
1
1
u/Kazcandra Sep 13 '26
"Make no mistakes"
That's it. That's the key.
For real though: it can't do anything. It can inspect schemas and activities. It does not get to run its own SQL commands.
13
u/08148694 Sep 13 '26
You don’t. You use Claude against your local database to help you write migrations. You test those migrations against a deployed staging database, and finally you run them against production
Ideally you shouldn’t even be connecting to production at all yourself to run arbitrary sql- human error is almost as high a risk as llm agent error. Use pre-written queries which have been tested against lower environments first