Prerequisites
The following example requires thesqlalchemy and openai libraries and a database URL.
PostgreSQL
For PostgreSQL, you can install thepsycopg adapter:
MySQL
For MySQL, you can install themysqlclient adapter:
mysqlclient adapter may have additional system-level dependencies. Please consult the official installation guide for more details.
You will also need a database. The following example uses a Postgres database running in a Docker container.
Example
The following agent will run a SQL query to list all tables in the database and describe the contents of one of the tables.cookbook/91_tools/sql_tools.py