Skip to main content

SQLsaber - Open-source agentic SQL assistant

Project description

SQLsaber

SQLsaber is an open-source agentic SQL assistant. Think Claude Code but for SQL.

Ask questions about your data in plain English. SQLsaber writes SQL queries, executes them, and explains the results.

demo

SQLsaber reads your schema, writes SQL, executes it, and explains the results—all from a single natural language prompt.

$ saber "How many orders were placed last month?"

# SQLsaber will:
# 1. Discover relevant tables (orders, order_items, etc.)
# 2. Analyze their schema
# 3. Generate and run SQL
# 4. Return results with explanation

Why SQLsaber?

  • No context switching — Stay in your terminal, ask questions, get answers
  • Schema-aware — Automatically introspects your database; no manual setup
  • Safe by default — Read-only queries; won't modify your data
  • Works with your stack — PostgreSQL, MySQL, SQLite, DuckDB, and CSV files

Install

# Recommended
uv tool install sqlsaber

# Or with pipx
pipx install sqlsaber

Then run:

saber

On first launch, SQLsaber walks you through connecting a database and setting up authentication.

Quick Examples

# Interactive mode
saber

# Single query
saber "show me users who signed up this week"

# Pipe from stdin
echo "top 10 customers by revenue" | saber

# Use a specific database
saber -d mydb "count active subscriptions"

Features

Feature Description
Schema introspection Discovers tables, columns, and relationships automatically
Knowledge discovery Discovers relevant saved knowledge automatically
Structured knowledge base Store searchable KPI definitions, SQL patterns, and domain notes per database
Thread history Resume past conversations with saber threads resume
Extended thinking Enable --thinking for complex analytical queries
Multiple AI providers Anthropic, OpenAI, Google, Groq (Claude Opus 4.5 by default)

Configuration

Add a database

saber db add mydb
# Prompts for connection details

Or pass a connection string directly:

saber -d "postgresql://user:pass@localhost:5432/mydb" "count users"

Change AI model

saber models set

Add knowledge (searchable KPI/query references)

# Add a structured knowledge entry
saber knowledge add "Revenue KPI" "Recognized revenue from shipped orders only" --sql "SELECT SUM(amount) FROM orders WHERE status = 'shipped'" --source "finance-wiki"

# Long description/SQL from files
saber knowledge add "Revenue definition" "$(cat ./knowledge/revenue_definition.md)" --sql "$(cat ./sql/revenue.sql)"

# Search saved knowledge
saber knowledge search "revenue shipped orders"

How It Works

  1. Discovery — Lists tables and identifies relevant ones based on your question
  2. Schema analysis — Introspects only the tables needed
  3. Query generation — Writes SQL tailored to your database dialect
  4. Execution — Runs read-only queries with safety checks
  5. Results — Formats output with explanations

Documentation

Full docs at sqlsaber.com:

Contributing

Contributions welcome! Please open an issue first to discuss changes.

If you find SQLsaber useful, a ⭐ on GitHub helps others discover it.

License

Apache-2.0 — see LICENSE

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

sqlsaber-0.63.0.tar.gz (8.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlsaber-0.63.0-py3-none-any.whl (165.4 kB view details)

Uploaded Python 3

File details

Details for the file sqlsaber-0.63.0.tar.gz.

File metadata

  • Download URL: sqlsaber-0.63.0.tar.gz
  • Upload date:
  • Size: 8.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sqlsaber-0.63.0.tar.gz
Algorithm Hash digest
SHA256 2e3b924a64e88ddbb1c179a983ac381d1b2c279d4d9dbfb00dfe4f9ef1e96660
MD5 d866b137ae44741724121771b26dacbc
BLAKE2b-256 bd27c655e4ba96d9bd12543c47c946c8f119e28ead820cb46c0aa0884a2cb366

See more details on using hashes here.

File details

Details for the file sqlsaber-0.63.0-py3-none-any.whl.

File metadata

  • Download URL: sqlsaber-0.63.0-py3-none-any.whl
  • Upload date:
  • Size: 165.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sqlsaber-0.63.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac312b1351ed827712c0c3712ae3fc474a838ba517eb061018eb4c814f440590
MD5 dda4b75b9bdf2bc5d5f6b7ef49e88620
BLAKE2b-256 bf59c1f56c8856122958eda163b86c9f4ff35e73786a9ee16c3d6cd3b9bdeb06

See more details on using hashes here.

Supported by

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