In the first part of this series, we built a basic AI-powered database agent. Now, it’s time to make a minimal viable product out of it. We’ll refine our scripts, add support for MySQL, incorporate OpenAI, and wrap everything in a user-friendly interface with Docker for easy deployment. Get ready to transform your data interactions into a seamless, intuitive experience.
I created OSADA—Open Source AI Database Agent—an experimental open source tool with a chat-like user interface that can convert text to SQL, query data from MySQL or PostgreSQL, and respond to human-language queries.

There are three main components in the tool:
The script itself is less than 100 lines of code and pretty rudimentary, but good enough for a demo.
There is a docker container for quick experimentation. The only caveat is that currently, it requires the user to set various environment variables.
It looks like this:
|
1 |
docker run -d <br>-e DB_TYPE='postgresql' <br>-e DB_HOSTNAME='mydb.company.com' <br>-e DB_USERNAME='pagila' <br>-e DB_PASSWORD='pagila' <br>-e DB_NAME='pagila' <br>-e LLM_PROVIDER="gemini" <br>-e GOOGLE_API_KEY='somesuperkey' <br>-e LLM_CHOICE="gemini-1.5-pro" <br>-p 8000:8000 perconasp/osada:0.0.2 |
This starts a container and exposes the UI on port 8000.
Read more in the usage guide.
The tool is currently in the experimental phase and was created solely for demonstration purposes. It has several obvious improvements.
Right now, various environment variables must be specified; otherwise, the script crashes. To make it more interactive, the Ask User feature of Chainlit could be used. That way, users can provide database and LLM credentials through the application itself.
Users can now query only a single database. We can make it possible to make smart queries across the fleet of database servers and perform correlation of results.
There are obvious improvements like making docker image smaller, adding authentication to the UI, and supporting more large language models (including self-hosted ones).
OSADA is an experimental tool that proves the concept that database agents can provide immense value. Users can now query databases with no SQL knowledge and zero understanding of how data is structured. Large Language Models will do the heavy lifting and do their best to fetch the answer.
Try OSADA right now, and let me know what you think. Check out the GitHub repository.
Resources
RELATED POSTS