I’ve created this repo on Github with code for an AI agent to use in database development.
There were a few reasons that I wanted to develop my own agent:
1) I wanted to dig in and see how an agent works. It was a lot less code that I thought it would be, most of the code was around making the tools for the agent to use.
2) I wanted for the agent to be able to read database schema and object definitions, but to not have access to data.
3) I wanted an agent to read and write new files, but not be able to change existing files, or delete files.
4) I wanted an agent that could use different models, and not be locked in to one provider.
This agent can use either the OpenAI or the Anthropic API. The agent can read SQL Server databases, but I’d like to extend it be able to read other database systems as well. I tried to use INFORMATION_SCHEMA views for metadata as much as I could, which should work with other systems. But a lot of creating the CREATE TABLE commands is SQL Server specific, so would need to be updated.
I considered using C# or Go for the agent code, but I ended up using Python. Python had packages to call to the AI APIs, and made it easy to put everything together. The place I work at is transitioning from Windows to Mac, so I wanted to keep things as OS agnostic as I could. This may not matter as much now, since the vast majority of SQL Server users are going to be on Windows, but this seemed like the most flexible option moving forward.
I did use AI to generate all of the tests, that was a huge help. I wrote all of the SQL myself, however. I’m still particular in what I want from SQL. AI was also a big help with errors, and getting me unstuck a few times.
I certainly learned a lot from writing the agent, as well as learning more about Python. I want to extend the tool to work with Postgres as well, that will probably be my next step with it.