About this app...

This is a demo Python Flask database app built out from information in this tutorial: "Chat with Your SQL Data Using ChatGPT" by MG

The engine is written in Python, presented through Flask.

Behind the scenes, here's what's happening:

  • Your question is called a "prompt", when you click the "submit" button your prompt is sent to the ChatGPT large language model via the OpenAI API.
  • Internally, the language model processes the input message using its trained neural network architecture.
  • The model analyzes the input, identifies patterns and looks through the database structure.
  • When it thinks its found the tables and information it's looking for, it builds and submits an SQL query to the database engine.
  • It translates the SQL reply from the database into regular written English and it's displayed on the page.

Q: What version of ChatGPT is this using??
A: Currently it is set to use GPT3.5-Turbo, aka "DaVinci".

Q: Is all this stuff free?
A: I'm afraid not. There's a small charge for every API call.

Q: How accurate are the answers?
A: Sometimes they are spot-on. Sometimes the answers are misleading, or outright incorrect. This can be because of the way the question is phrased. To get a better idea if you're getting good information in the answer, try asking your question in multiple ways to see if the answer changes.

Q: What's the database engine?
A: It's currently running on SQLite, but it can connect to virtually any database engine in common usage.

Q: Can I look at this database?
A: Two ways to do this. You can ask the AI any regular database question such as, "What tables are in the database" or you can also just download the test database here as an SQLite file. View with SQLite Studio.

Q: Is this code available somewhere?
A: I haven't posted it to github yet, but you can access the original tutorial here.

Q: Only English? Does it work in other languages?
A: It sure does! At the time of this writing you can also use French, Spanish, Russian and Chinese.

Q: Wouldn't the web UI be fancier if you used one of the many javascript frameworks?
A: Yes, but this is a demo of using OpenAI's ChatGPT talking to database, not of whizzy web UI's. Perhaps once I get this demo doing all the things I want it to do, I'll make a version with a whizzier web UI.

Q: What else is planned for this?
A: I do have plans for more features. You can read about it here.


– a demo by Tiki:Mojo Creative Services. Call us for a consultation.
– Stephen Peters
– June 17, 2023