Skip to main content

opendbpylot (Python)

Python bindings for opendbpylot — turn a natural-language question into SQL, run it on your database, and get the results. Uses Retrieval-Augmented Generation (RAG) with a self-repairing SQL loop.

pip install opendbpylot

This installs both a Python library and a fully-working dbpylot command — the whole CLI runs in-process from the native module, so no Rust toolchain is needed:

dbpylot init        # setup wizard
dbpylot             # chat with your database
dbpylot serve       # web UI
dbpylot ask "how many orders per country?"
dbpylot mcp         # serve as an MCP server for agent hosts (OpenPylot, Claude Desktop, …)

dbpylot mcp exposes the engine over the Model Context Protocol (stdio). Secrets can be set non-interactively for scripted setups: printf '%s' "$KEY" | dbpylot config set-key openai and dbpylot config set-db sqlite /data/app.db.

Usage (library)

First configure an LLM provider + a database. The bindings share the same config as the dbpylot CLI (install it with cargo install opendbpylot), so run the wizard once:

dbpylot init
# …or, from Python:
python -c "import opendbpylot; opendbpylot.OpenDbPylot.init()"

Then:

import opendbpylot

bot = opendbpylot.OpenDbPylot()
result = bot.ask("how many orders per country?")

print(result["sql"])          # the generated (and self-repaired) SQL
print(result["columns"])      # column names
for row in result["rows"]:    # result rows
    print(row)

# Teach it about your schema / business rules:
bot.train_documentation("Revenue excludes cancelled and refunded orders.")
bot.train_question_sql("top products", "SELECT name FROM products ORDER BY price DESC LIMIT 10;")

Fully self-contained web UI

You don't even need the CLI — launch the embedded web app straight from Python and configure everything (LLM + database) in the browser Settings panel:

import opendbpylot
opendbpylot.OpenDbPylot.serve()   # opens http://127.0.0.1:8080, runs until interrupted

API

  • OpenDbPylot() — load the engine from your saved configuration.
  • .ask(question) -> dict{sql, columns, rows, repairs_used, answer?}.
  • .train_ddl(ddl), .train_documentation(doc), .train_question_sql(q, sql).
  • OpenDbPylot.serve() — run the embedded web UI in-process (no CLI binary needed).
  • OpenDbPylot.init() / .doctor() — convenience shims that call the dbpylot CLI (install it with cargo install opendbpylot); serve() + Settings does the same setup.

Licensed under Apache-2.0.

Download files

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

Source Distribution

opendbpylot-0.3.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

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

opendbpylot-0.3.0-cp39-abi3-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

opendbpylot-0.3.0-cp39-abi3-macosx_11_0_arm64.whl (10.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

opendbpylot-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl (10.9 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file opendbpylot-0.3.0.tar.gz.

File metadata

  • Download URL: opendbpylot-0.3.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.15.0

File hashes

Hashes for opendbpylot-0.3.0.tar.gz
Algorithm Hash digest
SHA256 332c6730151f99c7844c45acfb278b1073ca16c728f97d96666c6e82a13b19c0
MD5 cec9e9590b7af49636efb094c413e83f
BLAKE2b-256 d0320b1db07a82a4f929008748805541d2452d46b900db4712edc8f41ab69d73

See more details on using hashes here.

File details

Details for the file opendbpylot-0.3.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for opendbpylot-0.3.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a4842b3322ded4fd1bba772a3b1b7c43dade07fcd900b34980cb657f9fe7faa
MD5 73de88b84f19f7278ecba6861db3b542
BLAKE2b-256 b9040e01971b59b7340c3e95334420abe0a8e5d0821895bad3e2b26d9b9369e6

See more details on using hashes here.

File details

Details for the file opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b885a2100389f2958665543fca66333d543048f50d5e183a301ee2375649f14
MD5 f890e30fedc028be8fba844b0d0f9534
BLAKE2b-256 d2606a849041a3881bc14bab772eeee7cd249c1dada170d0b15c19d69ad0c2a8

See more details on using hashes here.

File details

Details for the file opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for opendbpylot-0.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2bf549ea3889d50cc2f83b215e8ffde82f863f4016095b663dc805f9e65260e1
MD5 bbe66ed995f4658912be59ca9f1353cc
BLAKE2b-256 6a3001cf118d946d4ad013bdf0db15595919ce05c75306046b7e5cb49c117d46

See more details on using hashes here.

File details

Details for the file opendbpylot-0.3.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for opendbpylot-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 861b90d135c4744e26867ff19395a2ea81025a5331981865076e45b5c87eb80d
MD5 28add548f4f44a4befad4df4d7e32646
BLAKE2b-256 893d0d336ead0094b7cc0722584e7c26f4476278863117f153252d28b8c51ad0

See more details on using hashes here.

File details

Details for the file opendbpylot-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for opendbpylot-0.3.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 37cb2147ada7ee91aa0b7e1b4f770694e58a21e0df0293557cfae496f256ff65
MD5 303f6e1ca77938731e1249c0601c18cc
BLAKE2b-256 1f3b7a86743b00bf0778aa2e70095e42c9256e4d3126e044345337e0694655da

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 files

0.2.0

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page