Metadata-Version: 2.4
Name: psqlomni
Version: 0.1.4
Summary: LLM-powered chat interface to your Postgres database - (psql powered with Natural Language)
Author: emmakodes
Author-email: emmamichael65@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: all-models
Provides-Extra: anthropic
Provides-Extra: google
Provides-Extra: ollama
Requires-Dist: langchain (>=1.2.10,<2.0.0)
Requires-Dist: langchain-anthropic (>=0.3.20,<0.4.0) ; extra == "anthropic" or extra == "all-models"
Requires-Dist: langchain-community (>=0.4.1,<0.5.0)
Requires-Dist: langchain-google-genai (>=2.1.12,<3.0.0) ; extra == "google" or extra == "all-models"
Requires-Dist: langchain-ollama (>=0.3.8,<0.4.0) ; extra == "ollama" or extra == "all-models"
Requires-Dist: langchain-openai (>=1.1.9,<2.0.0)
Requires-Dist: langgraph (>=1.0.5,<2.0.0)
Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
Requires-Dist: toml (>=0.10.2,<0.11.0)
Description-Content-Type: text/markdown

# psqlomni

Natural language chat for your SQL database.

[![Build](https://img.shields.io/github/actions/workflow/status/emmakodes/psqlomni/release.yml?job=build&label=build)](https://github.com/emmakodes/psqlomni/actions/workflows/release.yml)
[![Test](https://img.shields.io/github/actions/workflow/status/emmakodes/psqlomni/ci.yml?branch=main&job=test&label=test)](https://github.com/emmakodes/psqlomni/actions/workflows/ci.yml)
[![Publish](https://img.shields.io/github/actions/workflow/status/emmakodes/psqlomni/release.yml?job=publish&label=publish)](https://github.com/emmakodes/psqlomni/actions/workflows/release.yml)

`psqlomni` translates plain English into SQL and runs it against your database with approval.

It supports SQLAlchemy-compatible databases and multiple model providers:

- OpenAI
- Anthropic
- Google Gemini
- Ollama

## Demo Video

![psqlomni demo](docs/psqlomnigif.gif)

## Install

```bash
pip install psqlomni
```

Optional provider extras:

```bash
pip install "psqlomni[anthropic]"
pip install "psqlomni[google]"
pip install "psqlomni[ollama]"
pip install "psqlomni[all-models]"
```

## Run

```bash
psqlomni
```

Or from source:

```bash
python -m psqlomni
```

## Quick Setup

Set either a full DB URI (recommended) or individual DB fields.

### Option 1: Full DB URI (recommended)

```bash
export DB_URI="postgresql+psycopg2://user:password@host:5432/dbname"
```

### Option 2: Individual DB Fields

```bash
export DBDIALECT="postgresql"
export DBHOST="localhost"
export DBPORT="5432"
export DBNAME="mydb"
export DBUSER="myuser"
export DBPASSWORD="mypassword"
```

### Model Provider

```bash
export MODEL_PROVIDER="openai"
export MODEL="gpt-4o-mini"
export OPENAI_API_KEY="your-key"
```

When values are missing, `psqlomni` prompts you interactively.

## What It Does

- Converts natural language prompts into SQL
- Shows SQL for approval before execution
- Lets you edit SQL before running it
- Retries when SQL fails, then asks for approval again
- Keeps conversation history for follow-up questions
- Supports a normal mode and a verbose trace mode

## Useful Commands

- `/help` - list commands
- `/connection` - show active DB and model
- `/connect` - connect to another database
- `/mode normal|verbose` - switch output detail
- `/provider` - show or set provider
- `/model` - show or set model
- `/new` - start a new thread
- `/resume <thread_id>` - resume a thread
- `/exit` - quit

## Safety

Every generated SQL query requires your approval before execution.

## Docs

- [Contributing](CONTRIBUTING.md)
- [Releasing](RELEASING.md)
- [Security](SECURITY.md)
- [Project docs](docs/)

