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.2.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.2.0-cp39-abi3-win_amd64.whl (10.3 MB view details)

Uploaded CPython 3.9+Windows x86-64

opendbpylot-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.3 MB view details)

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

opendbpylot-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

opendbpylot-0.2.0-cp39-abi3-macosx_11_0_arm64.whl (10.4 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

opendbpylot-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for opendbpylot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cbb2071ee658e42c9706845bd3dbeccdcafe50cf9fde825fd735b0520cd9c373
MD5 a4fc0a4d816c54ce36df2149169a883f
BLAKE2b-256 140c90d57755e9010df97eb1380b5dc4f4a0321084d6d61c43b94403ba03b6a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opendbpylot-0.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 322b67d64de22df3899020af4ff3d7245658dd41534d6a79ae988e1a4b8a7b06
MD5 f708998e44018313ab5a0cd58aeb716b
BLAKE2b-256 3dfe440f09e3a0c692ffabfa2cd7bcf3ce98fbae5d8289d73b7535a67a6d62d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opendbpylot-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9baaacb4323839fb2ceea50fbee85f86004145ae7bea00aa877a9d4831fe127b
MD5 95d313e0e99f7737be40e189380150bd
BLAKE2b-256 caa56f2b0fe697b4f6e9b875a8b771409a4fa77e9c59749921cd0359bb1d3f86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opendbpylot-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4ece14c5e27c97638b702b3ae8c3f277c41cced4897e0651edc2e5a48c90cd84
MD5 6f9553db0433a64843c6fac060d60dac
BLAKE2b-256 b282a657d4328d078cb97bcd69b28f3868e0e29489886aedd606e500a6311666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opendbpylot-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 795ba69948be399efb7078b21d928af76608a68f813c849d5314c60387782869
MD5 97553e494b3ea198db45eab573e7f515
BLAKE2b-256 28539f26a3005157e2fa615fcdf02a7fee0a9a85e49c7b9721fd9ce45abdac99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opendbpylot-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a9209c399710a3403e754411dc0ca6013406437adf830b2b1892ea1fb8f81be6
MD5 9fbc6d5b8d71ac1a2604ad10b8fbf3e7
BLAKE2b-256 480088b454bfa3264988c5b1c2d6414b18470e57ec9076f14cf63da935d2e33a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

6 files

This release

0.2.0 This release

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