Skip to main content

SQLSaber - Agentic SQL assistant like Claude Code

Project description

SQLSaber

Use the agent Luke!

SQLSaber is an agentic SQL assistant. Think Claude Code but for SQL.

Ask your questions in natural language and it will gather the right context and answer your query by writing SQL and analyzing the results.

Features

  • Natural language to SQL conversion
  • 🔍 Automatic database schema introspection
  • 🛡️ Safe query execution (read-only by default)
  • 🧠 Memory management
  • 💬 Interactive REPL mode
  • 🎨 Beautiful formatted output with syntax highlighting
  • 🗄️ Support for PostgreSQL, SQLite, and MySQL

Installation

uv tool install sqlsaber

or

pipx install sqlsaber

Configuration

Database Connection

Set your database connection URL:

saber db add DB_NAME

This will ask you some questions about your database connection

AI Model Configuration

SQLSaber uses Sonnet-4 by default. You can change it using:

saber models set

# for more model settings run:
saber models --help

Memory Management

You can add specific context about your database to the model using the memory feature. This is similar to how you add memory/context in Claude Code.

saber memory add 'always convert dates to string for easier formating'

View all memories

saber memory list

You can also add memories in an interactive query session by starting with the # sign

Usage

Interactive Mode

Start an interactive session:

saber query

You can also add memories in an interactive session by starting your message with the # sign

Single Query

Execute a single natural language query:

saber query "show me all users created this month"

Database Selection

Use a specific database connection:

# Use named database from config
saber query -d mydb "count all orders"

Examples

# Show database schema
saber query "what tables are in my database?"

# Count records
saber query "how many active users do we have?"

# Complex queries with joins
saber query "show me orders with customer details for this week"

# Aggregations
saber query "what's the total revenue by product category?"

# Date filtering
saber query "list users who haven't logged in for 30 days"

# Data exploration
saber query "show me the distribution of customer ages"

# Business analytics
saber query "which products had the highest sales growth last quarter?"

How It Works

SQLSaber uses an intelligent three-step process optimized for minimal token usage:

🔍 Discovery Phase

  1. List Tables Tool: Quickly discovers available tables with row counts
  2. Pattern Matching: Identifies relevant tables based on your query using SQL LIKE patterns

📋 Schema Analysis

  1. Smart Introspection: Analyzes only the specific table structures needed for your query
  2. Selective Loading: Fetches schema information only for relevant tables

⚡ Execution Phase

  1. SQL Generation: Creates optimized SQL queries based on natural language input
  2. Safe Execution: Runs queries with built-in protections against destructive operations
  3. Result Formatting: Presents results with syntax highlighting and explanations

Contributing

Contributions are welcome! Please feel free to open an issue to discuss your ideas or report bugs.

License

This project is licensed under Apache-2.0 License - see the LICENSE file for details.

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.1.0.tar.gz (58.8 kB view details)

Uploaded Source

Built Distribution

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

sqlsaber-0.1.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlsaber-0.1.0.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.14

File hashes

Hashes for sqlsaber-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e7ccf6586ac78c2dfb1d89803bfbc50e75e4c212f023b772d7b45ec12e64757
MD5 92c257f236d0a738205c163b6ebd9f37
BLAKE2b-256 faa00f88a1ad28097c4287eaa0cc10f6e7573665e7686d02dcc8f4bc0ec8b5f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlsaber-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.14

File hashes

Hashes for sqlsaber-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5317170d8e043823e0474a3bac7c02a294bed026fa71e23f4fc2cd3fb1c9e258
MD5 2201e835e9358882165353c1c0ad1ecd
BLAKE2b-256 b7853d539de5cc877f65c674e0d44a503a8e7f5608e23bc13f2ff1a0bc9b82e9

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