Skip to main content

LLM-powered chat interface to your Postgres database - (psql powered with Natural Language)

Project description

psqlomni

(psql powered with natural language)

An LLM-powered chat interface to your database. This tool understands Postgres syntax and can easily translate English queries into proper SQL queries. Uses Langchain and Open AI model.

This provides the quickest way to enable LLM chat with your data - no preparation is needed.

Here's a quick demo showing natural language queries:

https://github.com/emmakodes/psqlomni/assets/34986076/0c58f4fd-c359-47c2-8e3c-4b068545e522

Installation

You will need:

  1. credentials for your database
  2. an OpenAI API Key from your OpenAI account.

then

pip install psqlomni

or download the source.

Run the CLI with:

psqlomni

or use python -m psqlomni to run from source.

What can it do?

The Open AI model understands most Postgres syntax, so it can generate both generic SQL commands as well as very Postgres-specific ones like querying system settings.

The LLM is also good at analyzing tables, understanding what they are likely used for, and inferring relationships between tables. It is good at writing JOINs between tables without explicit instruction.

It can write queries to group and summarize results.

It also maintains a history of the chat, so you can easily ask follow up questions.

Configuration

You can configure the database connection either using psql style command line arguments or the env vars DBHOST, DBNAME, DBUSER, DBPASSWORD, DBPORT.

Else when you first run the program it will prompt you for the connection credentials as well as your OpenAI API key.

After first setup all the configuration information is stored in ~/.psqlomni. Delete that file if you want to start over.

How it works

psqlomni uses Langchain and the OpenAI model to create an agent to work with your database.

When requested the LLM automatically generates the right SQL, ask if to execute the query, if yes(or y), it executes the query. The query results are then returned. If an error is returned, it rewrites the query, check the query, ask for confirmation to execute query and then try again.

Command Reference

There are a few system commands supported for meta operations:

help - show system commands

connection - show the current db connection details, and the active LLM model

exit or ctrl-c to exit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psqlomni-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

psqlomni-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file psqlomni-0.1.0.tar.gz.

File metadata

  • Download URL: psqlomni-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.0 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for psqlomni-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e895398fb4282702a344ffc684eedfc2ef6ac54b9fc7629a218e5ea2f6f4f41d
MD5 9fb761cdc5d38696df571b37f03f05d6
BLAKE2b-256 20c487adb8e8ffc8f1bf3ea41420d617f3c60e0d3a7a8c5b7ff20ad894e873e2

See more details on using hashes here.

File details

Details for the file psqlomni-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: psqlomni-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.0 CPython/3.10.12 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for psqlomni-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d43a21f0fd15d467dfe2edd040bb17c4299cfefd0a2ffa1baea196296b56ea2a
MD5 6ecb0793695680c8bffa41dd8a57913d
BLAKE2b-256 f3f584a6125f1ee4525bc9d13e96514402b8098e72492b20d8b08d664d4cb24a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page