Postgres extension for natural language queries
Top 67.5% on sourcepulse
This experimental PostgreSQL extension enables natural language querying by integrating with OpenAI's GPT API. It's designed for users who want to interact with their databases using plain English, translating natural language requests into SQL queries.
How It Works
The extension sends a subset of the database schema (table names and columns, not data) to the OpenAI GPT API. It then prompts the model to generate a SQL query based on the provided schema and the user's natural language input. This approach allows for intuitive database interaction without requiring users to know SQL syntax.
Quick Start & Requirements
pgx
(Postgres Extension Framework). Install pgx
via cargo install --locked cargo-pgx
and cargo pgx init
. Then, clone the repository, set OPENAI_KEY
, and run cargo pgx run
.cargo-pgx
, PostgreSQL, and an OpenAI API key.create extension pg_gpt;
and set openai.key = '<YOUR OPENAPI API KEY HERE>';
. Use the gpt()
function, e.g., select gpt('show me all open aws s3 buckets');
.Highlighted Details
gpt(text)
for full schema queries and gpt_tables(table_pattern, text)
to limit schema context.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The extension uses gpt-3.5-turbo
, which has a token limit of 4096, potentially impacting performance with very large schemas. It is explicitly not recommended for production databases due to its experimental nature and the transmission of schema information to a third-party API.
2 years ago
Inactive