IntegrationsDatabasesPostgres

Postgres

Description: Enable agents to interact with PostgreSQL databases (read only).

Author: Arcade

Code: GitHub

Auth: database connection string

PyPI VersionLicensePython VersionsWheel StatusDownloads

The Arcade Postgres toolkit provides a pre-built set of tools for interacting with PostgreSQL databases in a read-only manner.

This toolkit is meant to be an example of how to build a toolkit for a database, and is not intended to be used in production. For production use, we recommend forking this repository and building your own toolkit with use-case specific tools.

This repository demonstrates a few concepts to aid in LLM-powered database interactions.

  • Re-use an existing database pool for all tool calls
  • Enforce read-only access to the database
  • Hint to the LLM that both table and schema discovery is required before executing a query
  • Enforce a limit on the number of rows returned by a query

Available Tools

Tool NameDescription
Postgres.DiscoverTablesDiscover all tables in a PostgreSQL database.
Postgres.GetTableSchemaGet the schema of a table in a PostgreSQL database.
Postgres.ExecuteQueryExecute a query on a PostgreSQL database.

Note that all tools require the DATABASE_CONNECTION_STRING secret to be set.

Postgres.DiscoverTables

Discover all tables in a PostgreSQL database.

Postgres.GetTableSchema

Get the schema of a table in a PostgreSQL database.

Postgres.ExecuteQuery

Execute a query on a PostgreSQL database. Be sure that your agent runs the Postgres.DiscoverTables and Postgres.GetTableSchema tools before executing a query.