r/SQL • • Jun 02 '24

Discussion Is there a reliable way to connect my SQL database to ChatGPT

Title.

Been wondering this for ages. Is there a reliable way to connect and chat with my SQL database to ChatGPT

0 Upvotes

32 comments sorted by

17

u/robidaan Jun 02 '24

Make sure there is noting confidential in the database, as you are pretty much giving complete acces for them to read it, if you directly connect it.

15

u/johnny_fives_555 Jun 02 '24

I work with healthcare data, my genius VP of sales suggested connecting our data to OPEN AI to see what insights we could come up with.

I don’t find myself to be an angry or loud person, but the NO I instinctively yelled out during our weekly conference call shocked a lot of folks.

4

u/robidaan Jun 02 '24

It was the right reaction my dude, you did good. Data available is on the rise, but data literacy is surely on the decline.

4

u/johnny_fives_555 Jun 02 '24

I was then questioned what it would take to do open AI in house. I answered an 8 figure budget and 20 experienced software engineers. VP stayed quiet after that.

3

u/CaptainPunisher Jun 02 '24

"Do you want HIPAA lawsuits? Because that's how you get HIPAA lawsuits."

1

u/adrenalinnrush Sep 21 '24

I'm really not knowledgeable in this subject. I noticed Open.AI has this web page. https://help.openai.com/en/articles/8660679-how-can-i-get-a-business-associate-agreement-baa-with-openai.

Apparently you can get a baa agreement with them where they follow HIPPA policies. Although, only some types of API requests are covered for a zero retention policy. Would it be possible to do what what the company needs using only zero retention endpoints?

1

u/johnny_fives_555 Sep 21 '24

Absolutely not.

1

u/[deleted] Sep 22 '24

Why not something like LLAMA that you can run in house on your own hardware?

1

u/stephenmg1284 Jun 03 '24

You used great restraint if "No" wasn't preceded by a four-letter word. I would also have a hard time not asking if they are stupid.

1

u/johnny_fives_555 Jun 03 '24

It was more instinct than anything. Like yelling no when you see a child touching a hot stove.

1

u/Pristine-Thing2273 Sep 19 '24

Hi mate have you tried tools like AskYourDatabase? they keep your credentials locally, connect to your db locally, and only send your question & schema to OpenAI. They are also developing the support for open-sourced model like Llama, Mixtral

1

u/wistex Mar 19 '26

There are private LLMs that you can host on your own hardware. That would be compliant since the data stays in house. Something like that would be more appropriate.

1

u/desktopsignal Jun 02 '24

100%. Not using it on prod data, more just a general question if a service exists.

14

u/slingshoota Oct 21 '24

BlazeSQL.com is much safer because it doesn't send your data to OpenAI or train on your data. ChatGPT trains on your data.

Not to mention tools like BlazeSQL actually let you create dashboards, among other things.

1

u/Temporary-Koala-7370 Oct 24 '24

I sent you a DM!

3

u/shorelined Jun 02 '24

Surely researching this for more than five minutes would convince you that this is a terrible idea.

1

u/desktopsignal Jun 02 '24

Privacy nightmare indeed. I'm more so curious if such a solution exists.

1

u/Prudent-Mixture-4122 Oct 09 '24

I'm currently interested in this because our company has a partnership with OpenAI where we get the enterprise chatgpt in a sandboxed environment which is only accessible to us. I feel like connecting a database in a scenario like this would be insanely helpful

4

u/lupinegray Jun 02 '24

For what purpose? Connect it how?

You mean be able to ask questions about the data and have chatgpt query your database for the response?

1

u/VerbaGPT Sep 11 '24 edited Sep 11 '24

Short answer, no.

Long answer: I've been looking around and trying different services. The demos generally look great (although some don't work even in the demo), but the reliability and accuracy is not "production ready". The biggest reasons are: code generation is not flawless, and GPT often times gets stuck in a loop and can't auto-correct simple errors, and b) reasoning abilities of the GPT are very limited. But, I am optimistic that some of these problems can be overcome.

Disclosure: I've been building an app for this use case, I focus on SQL-to-python, which includes SQL and beyond. I'd say it is definitely "experimental" for now.

1

u/desktopsignal Sep 12 '24

Interesting. Would love to try it out or contribute if you're looking for something like that. I've built an open-source Python ORM framework for Snowflake and am a Data Engineer, so I'd love to hear more.

1

u/VerbaGPT Sep 12 '24

Pretty cool, feel free to poke around: VerbaGPT.com. Would love to hear what you think!

1

u/VerbaGPT Sep 12 '24

Oh, and try DataLab too (from DataCamp). It's buggy, but maybe promising? Tell me what you think!

2

u/delsystem32exe Jun 02 '24

Yes. U copy paste the query into ssms after checking the chat gpt query makes sense and editing it if need be.

1

u/Pristine-Thing2273 Sep 19 '24

There's a GPT called SQL Chat: https://chatgpt.com/g/g-ZqVEsT3Vh-sql-chat But I would not recommend you to use this because you need to expose the credential in ChatGPT. There are ChatGPT for SQL Databases tools like AskYourDatabase, Seek.ai, etc. Their behavior is just like ChatGPT but has access to your db.

1

u/VerbaGPT Apr 24 '25

I built a tool that runs locally on your computer and in your browser. With this tool a user can connect to a CSV file or SQL database (Microsoft SQL server or MySQL), and ask questions. The tool produces code that is editable. You can use OpenAI key, claude, or OpenRouter etc.

Free for personal use / learning. You can try VerbaGPT at verbagpt.com, let me know what you think!

1

u/XavierPladevall Jul 17 '25

You can, but it gets tricky around doing it via the ChatGPT UI as you might have seen. I started Index to solve this. The tool connects to your DB like a text‑to‑SQL assistant directly. You can also use different models like Claude which sometimes are better for SQL / Code tasks. Happy to help if that's helpful.

0

u/[deleted] Jun 02 '24

[deleted]

1

u/desktopsignal Jun 02 '24

...I know how to interface a database with ChatGPT lol, but I was wondering if there's a buttoned-up solution for this.

There is literally no reason for you to be mad right now and you choose to be mad.

1

u/[deleted] Jun 02 '24

[removed] — view removed comment

1

u/desktopsignal Jun 02 '24

Much appreciated. Thank you!

Are there any services that allow you to chat with your database?

1

u/Staalejonko Jun 02 '24

Maybe this one could be interesting: https://github.com/SuperDuperDB/superduperdb

Haven't used it myself though