QueryPilot
What it does
Safe SQL gateway for AI agents: SELECT-only validation, access policies, masking, audit trail, evals
- Connects パソコンで動く
- Account or key Needs QUERYPILOT_DATABASE_URL
- Category データベース・データセット
インストール
使っているAIアプリを選んで、設定をコピーしてください。
チェック 3/3 合格 · あなたのパソコンで動きます · ✓ コマンド確認済み 2026年11月14日
まず:どの AI を使っていますか?
使っているアプリを選ぶと、下に手順が表示されます。
Claude につなげますが、先に準備が必要です
QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
パソコン版 Claude アプリの設定ファイルを開く
SettingsDeveloperEdit Config
この設定を貼り付けて保存
{ "mcpServers": { "querypilot": { "command": "uvx", "args": [ "querypilot", "mcp" ], "env": { "QUERYPILOT_DATABASE_URL": "your-value" } } } }キーはアプリの入力欄にだけ貼り付け、チャットに貼ったり人に送ったりしないでください
Claude を終了してもう一度開く
試してみる
QueryPilot を使って、私に何ができるか教えて、1 つやってみせて✓ Claude が QueryPilot を使っていると言うか、回答に QueryPilot のツール名が出れば接続成功です
追加の設定 5 項目(入力しなくても使えます)
上のコマンドはこれらがなくても動きます。変えたいときだけ作者の説明に沿って追加してください。
QUERYPILOT_DIALECTSQL dialect for the connector. Equivalent to --dialect. · 初期値 sqliteQUERYPILOT_MAX_ROWSMaximum rows returned per query. Equivalent to --max-rows. · 初期値 100QUERYPILOT_TIMEOUT_SECONDSQuery execution timeout in seconds. Equivalent to --timeout-seconds. · 初期値 10QUERYPILOT_ACCESS_POLICY_JSONJSON-encoded AccessPolicy (blocked_columns, allowed_columns, row_filters, masking_rules) enforced before execution. Equivalent to --access-policy-json.QUERYPILOT_MCP_TRANSPORTMCP transport used by `querypilot mcp`. Equivalent to --transport. Most MCP clients should leave this at stdio; streamable-http is for clients that speak Streamable HTTP directly. · 初期値 stdio
説明は英語の原文のままです。
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
ChatGPT はまだ QueryPilot につなげません
QueryPilot はパソコンに入れて使うものですが、ChatGPT は Web 上で動くサーバーにしかつなげません
代わりにできること
A · QueryPilot につなげるアプリを使う
- QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ) · パソコン版 Claude アプリ(Windows または Mac)のみ。Web やスマホでは使えません
- QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
- QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
- QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
B · データベース・データセット の中で ChatGPT につなげる別のサーバー
同じカテゴリでよく使われているものから、キーなしでアドレスだけでつなげるものを選びました
- Supabase✓ ChatGPT
- Appwrite MCP✓ ChatGPT
- Pg Aiguide✓ ChatGPT
Claude Code につなげますが、先に準備が必要です
QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
ターミナルを開く
Mac:Command+スペースで Terminal と入力 · Windows:PowerShell を開く
このコマンドを貼り付けて Enter
claude mcp add --scope user querypilot --env QUERYPILOT_DATABASE_URL=your-value -- uvx querypilot mcpEnter の前に「your-value」を自分のキーに書き換えてください
キーはアプリの入力欄にだけ貼り付け、チャットに貼ったり人に送ったりしないでください
Claude Code で /mcp と入力
QueryPilot が一覧にあり、接続済みと表示されれば OK です
試してみる
QueryPilot を使って、私に何ができるか教えて、1 つやってみせて✓ Claude Code が QueryPilot を使っていると言うか、回答に QueryPilot のツール名が出れば接続成功です
追加の設定 5 項目(入力しなくても使えます)
上のコマンドはこれらがなくても動きます。変えたいときだけ作者の説明に沿って追加してください。
QUERYPILOT_DIALECTSQL dialect for the connector. Equivalent to --dialect. · 初期値 sqliteQUERYPILOT_MAX_ROWSMaximum rows returned per query. Equivalent to --max-rows. · 初期値 100QUERYPILOT_TIMEOUT_SECONDSQuery execution timeout in seconds. Equivalent to --timeout-seconds. · 初期値 10QUERYPILOT_ACCESS_POLICY_JSONJSON-encoded AccessPolicy (blocked_columns, allowed_columns, row_filters, masking_rules) enforced before execution. Equivalent to --access-policy-json.QUERYPILOT_MCP_TRANSPORTMCP transport used by `querypilot mcp`. Equivalent to --transport. Most MCP clients should leave this at stdio; streamable-http is for clients that speak Streamable HTTP directly. · 初期値 stdio
説明は英語の原文のままです。
メニュー名は 2026年11月11日 に Anthropic のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
Cursor につなげますが、先に準備が必要です
QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
キーを入力
QueryPilot の設定で QUERYPILOT_DATABASE_URL が空です。自分のキーを入れて保存します
キーはアプリの入力欄にだけ貼り付け、チャットに貼ったり人に送ったりしないでください
Cursor の AI チャットを Agent モードで開く
試してみる
QueryPilot を使って、私に何ができるか教えて、1 つやってみせて✓ Cursor が QueryPilot を使っていると言うか、回答に QueryPilot のツール名が出れば接続成功です
追加の設定 5 項目(入力しなくても使えます)
上のコマンドはこれらがなくても動きます。変えたいときだけ作者の説明に沿って追加してください。
QUERYPILOT_DIALECTSQL dialect for the connector. Equivalent to --dialect. · 初期値 sqliteQUERYPILOT_MAX_ROWSMaximum rows returned per query. Equivalent to --max-rows. · 初期値 100QUERYPILOT_TIMEOUT_SECONDSQuery execution timeout in seconds. Equivalent to --timeout-seconds. · 初期値 10QUERYPILOT_ACCESS_POLICY_JSONJSON-encoded AccessPolicy (blocked_columns, allowed_columns, row_filters, masking_rules) enforced before execution. Equivalent to --access-policy-json.QUERYPILOT_MCP_TRANSPORTMCP transport used by `querypilot mcp`. Equivalent to --transport. Most MCP clients should leave this at stdio; streamable-http is for clients that speak Streamable HTTP directly. · 初期値 stdio
説明は英語の原文のままです。
メニュー名は 2026年11月11日 に Cursor のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
VS Code につなげますが、先に準備が必要です
QueryPilot のキーが必要です(提供元のサイトで作成) · 先にパソコンへ Python (uv) を入れてください(1 回だけ)
キーを入力
QueryPilot の設定で QUERYPILOT_DATABASE_URL が空です。自分のキーを入れて保存します
キーはアプリの入力欄にだけ貼り付け、チャットに貼ったり人に送ったりしないでください
VS Code の AI チャットを Agent モードで開く
試してみる
QueryPilot を使って、私に何ができるか教えて、1 つやってみせて✓ VS Code が QueryPilot を使っていると言うか、回答に QueryPilot のツール名が出れば接続成功です
追加の設定 5 項目(入力しなくても使えます)
上のコマンドはこれらがなくても動きます。変えたいときだけ作者の説明に沿って追加してください。
QUERYPILOT_DIALECTSQL dialect for the connector. Equivalent to --dialect. · 初期値 sqliteQUERYPILOT_MAX_ROWSMaximum rows returned per query. Equivalent to --max-rows. · 初期値 100QUERYPILOT_TIMEOUT_SECONDSQuery execution timeout in seconds. Equivalent to --timeout-seconds. · 初期値 10QUERYPILOT_ACCESS_POLICY_JSONJSON-encoded AccessPolicy (blocked_columns, allowed_columns, row_filters, masking_rules) enforced before execution. Equivalent to --access-policy-json.QUERYPILOT_MCP_TRANSPORTMCP transport used by `querypilot mcp`. Equivalent to --transport. Most MCP clients should leave this at stdio; streamable-http is for clients that speak Streamable HTTP directly. · 初期値 stdio
説明は英語の原文のままです。
メニュー名は 2026年11月11日 に VS Code のヘルプページで確認 · アプリのバージョンにより画面が少し違うことがあります
開発者向け:ターミナルのコマンドと JSON 設定
パソコンにインストール
Claude Code
claude mcp add --scope user querypilot --env QUERYPILOT_DATABASE_URL=your-value -- uvx querypilot mcpClaude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"querypilot": {
"command": "uvx",
"args": [
"querypilot",
"mcp"
],
"env": {
"QUERYPILOT_DATABASE_URL": "your-value"
}
}
}
}Cursor (~/.cursor/mcp.json)
{
"mcpServers": {
"querypilot": {
"command": "uvx",
"args": [
"querypilot",
"mcp"
],
"env": {
"QUERYPILOT_DATABASE_URL": "your-value"
}
}
}
}VS Code (mcp.json)
{
"servers": {
"querypilot": {
"type": "stdio",
"command": "uvx",
"args": [
"querypilot",
"mcp"
],
"env": {
"QUERYPILOT_DATABASE_URL": "your-value"
}
}
}
}自分で入力する値
QUERYPILOT_DATABASE_URL秘密 必須 envSQLAlchemy-style database connection URL, e.g. sqlite:///demo.db or postgresql://user:pass@host:5432/db. Equivalent to --database-url.QUERYPILOT_DIALECTenvSQL dialect for the connector. Equivalent to --dialect.QUERYPILOT_MAX_ROWSenvMaximum rows returned per query. Equivalent to --max-rows.QUERYPILOT_TIMEOUT_SECONDSenvQuery execution timeout in seconds. Equivalent to --timeout-seconds.QUERYPILOT_ACCESS_POLICY_JSONenvJSON-encoded AccessPolicy (blocked_columns, allowed_columns, row_filters, masking_rules) enforced before execution. Equivalent to --access-policy-json.QUERYPILOT_MCP_TRANSPORTenvMCP transport used by `querypilot mcp`. Equivalent to --transport. Most MCP clients should leave this at stdio; streamable-http is for clients that speak Streamable HTTP directly.
説明は英語の原文のままです。
この設定は、作者のレジストリ登録情報から作成しています。READMEと違う場合は、READMEに従ってください。
ひと目でわかる
- 週あたりのダウンロードi
- 16/週
- 接続方法
- パソコンで動く
- トランスポート
- stdio
- 最新バージョンi
- 0.1.1
- カテゴリi
- データベース・データセット
- レジストリ公開日i
- 2026年7月12日
- コードの最終更新i
- 2026年10月24日
- 作者
- nickklos10
- パッケージ
pypi: querypilot- ウェブサイト
- github.com
- レジストリでの状態
- 有効
使えるアプリ
このサーバーのつなぎ方と、各アプリの公式ドキュメントに基づきます。2026年11月10日に確認。
パソコン上で動かせるアプリ
ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast
できること
パソコンで動くサーバーです。インストールすると、ツール一覧がAIアプリに表示されます。
基本チェックi
誰でも見られる情報をチェックしており、コードは読んでいません。当てはまらない項目は数に入れていません。 · 2026年11月14日にチェック
- ✓ 合格
作者とリポジトリが一致
レジストリ名は、リポジトリを所有するGitHubアカウント nickklos10 で確認済みです
- ✓ 合格
今もメンテナンスされている
コードの最終更新:21 日前
- ✓ 合格
ライセンスがある
MITを使用
- – 対象外
エンドポイントが応答する
これはパソコンで動くため、インターネット上のエンドポイントはありません
- – 対象外
OAuthでサインイン
パソコンで動き、代わりにローカルの設定を使います
- … 未チェック
ツールの説明に隠れた指示がない
パソコンで動くサーバーです。ツール一覧を読み取れるのは、インターネット上のエンドポイントがある場合だけです
話し合い
質問、コツの共有、使えないことの報告ができます。「役に立った」の多い順です。
ユーザーレビュー
まだレビューはありません
データベース・データセットのほかのサーバーとの比較i
- このカテゴリのほかの1194件のうち86%よりスターが多い
- このカテゴリのほかの1194件のうち17%より最近レジストリに公開
- 基本チェックの結果が、このカテゴリのほかの1194件のうち100%と同じかそれ以上
レジストリでこのカテゴリにある有効なすべてのサーバーと比較しています。スターは、公開者がリポジトリの所有者である場合だけ数えます。
よくある質問
QueryPilotは安全ですか?
当てはまる基本チェック3項目のうち3項目に合格しました。コードは読んでいません。キーやトークンを追加する前に、サーバーがどんなアクセスを求めているかを確認し、必要な権限だけを持つキーを使ってください。
どんなキーやコードが必要ですか?
入力が必要なもの:QUERYPILOT_DATABASE_URL
パソコンで動きますか、それともクラウドですか?
あなたのパソコンで動きます。必要なときにAIアプリが起動し、データは作者のサーバーを通りません(サーバー自体がオンラインサービスを呼び出す場合を除きます)。
今もメンテナンスされていますか?
GitHubリポジトリの最終更新は21 日前、最新バージョン(0.1.1)がレジストリに届いたのは4 か月前です。
どのアプリで使えますか?
Claude Desktop、Claude Code、Cursor、VS CodeなどのMCP対応アプリで使えます。パソコンにPython (uv)も必要です。
代わりに使えるものは?
同じカテゴリには:Dbx, MCP Toolbox for Databases, MCP Toolbox for Databases
同じカテゴリのほかの候補
同じカテゴリで、ほかの作者が作ったサーバー。スターの多い順。
カードの見方:↓ 週あたりのダウンロードi★ GitHubスターi3つの柱:レビュー · チェック · 利用状況i更新=最新バージョンをレジストリに公開した日i
MCP Toolbox for Databases
MCP Toolbox for Databases enables your agent to connect to your database.
MCP Toolbox for Databases
MCP Toolbox for Databases enables your agent to connect to your database.
作者のREADME
READMEを開く
作者のリポジトリから書かれたとおりにコピーしたものです。PopNx MCPは内容を確認・推奨していません。HTML、画像、スクリプトは取り除いています。リンクはこのサイトの外へ移動します。
QueryPilot
Safe, measurable SQL for AI agents.
QueryPilot sits between an LLM agent and your database. It gives the agent read-only, policy-checked SQL tools for any SQLAlchemy database. It grounds the model in your real schema, feeds errors back so the model can fix its SQL, and ships an eval harness that proves the SQL is correct and stays correct.
Quickstart
pip install querypilot
querypilot demo
querypilot demo writes a small SaaS database (querypilot-demo.db), runs a validated query against it and shows a blocked DELETE. Then try:
querypilot schema --db sqlite:///querypilot-demo.db # list tables
querypilot schema --db sqlite:///querypilot-demo.db invoices # columns, keys, sample values querypilot sql --db sqlite:///querypilot-demo.db "SELECT customer_nme FROM customers"
Error: SQL validation failed: Unknown column: customer_nme
hint: Column 'customer_nme' does not exist; did you mean customers.customer_name, ...?
querypilot ask --db sqlite:///querypilot-demo.db "Which customers have the highest ARR?"
ask uses OpenAI or Anthropic when OPENAI_API_KEY or ANTHROPIC_API_KEY is set (--generator openai-compatible covers Ollama, vLLM and LM Studio). Without a key it falls back to an offline demo generator.
For your own database, querypilot init --db postgresql://analyst@db.internal/prod writes a querypilot.yaml that holds the connection, business hints, column descriptions and access policy. Every command, the MCP server and QueryPilot.from_config() read it, so you can drop --db from then on.
In Python:
from querypilot import QueryPilot
qp = QueryPilot.connect("postgresql://analyst@db.internal/prod") # dialect inferred from the URL
result = qp.execute_sql("SELECT plan, COUNT(*) FROM subscriptions GROUP BY plan") print(result.sql) # rewritten with a LIMIT, validated against the live schema print(result.rows)
Connect any database
QueryPilot.connect(url) infers the SQL dialect from the URL and introspects tables, views, primary and foreign keys, and comments. It also accepts a SQLAlchemy Engine.
| Database | URL | Install |
|---|---|---|
| SQLite | sqlite:///app.db | included |
| PostgreSQL | postgresql://user:pass@host/db | included |
| DuckDB | duckdb:///analytics.duckdb | pip install "querypilot[duckdb]" |
| MySQL / MariaDB | mysql+pymysql://user:pass@host/db | pip install "querypilot[mysql]" |
| SQL Server | mssql+pyodbc://… | pip install "querypilot[mssql]" |
| Snowflake | snowflake://user@account/db/schema | pip install "querypilot[snowflake]" |
| BigQuery | bigquery://project/dataset | pip install "querypilot[bigquery]" |
| Redshift | redshift+psycopg2://… | pip install "querypilot[redshift]" |
| Trino / Oracle / Databricks | trino://…, oracle+oracledb://…, databricks://… | querypilot[trino], [oracle], [databricks] |
Every query is validated with sqlglot for the target dialect. Validation means one statement, SELECT only, and known tables and columns. It also blocks dangerous functions for each engine, such as pg_read_file, DuckDB's read_csv, MySQL's LOAD_FILE and SQL Server's xp_cmdshell. Execution then adds the engine's own guard: a read-only transaction on Postgres, MySQL and Oracle, a read-only connection on DuckDB, and a statement timeout where the engine supports one. Every query runs in a transaction that is always rolled back. For warehouses that have no read-only session mode, connect with a read-only role.
Give your agent the tools
Every integration exposes the same small toolset. Results are compact JSON, and errors come back as {"ok": false, "error": ..., "hints": [...]} rather than as exceptions, so the agent can correct itself.
| Tool | What it does |
|---|---|
list_tables | Tables and views the policy allows, with comments |
describe_table | Columns, types, keys, comments and sample values for the named tables |
search_schema | Finds tables and columns relevant to a question |
validate_sql | Checks SQL and returns the rewritten form, errors and "did you mean" hints |
run_sql | Validates and runs SQL, returning rows with a truncated flag at max_rows |
ask_database | Natural language → validated SQL → rows (only when an LLM generator is configured) |
MCP (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf):
querypilot mcp-config claude-code --db postgresql://analyst@db/prod
claude mcp add querypilot --env QUERYPILOT_DATABASE_URL=... -- /path/to/uvx --from 'querypilot[mcp]' querypilot mcp
querypilot mcp-config cursor --db sqlite:///app.db # prints the mcpServers JSON block
The generated config uses the absolute path to uvx, which avoids the common spawn uvx ENOENT failure. Pass --runner python to launch the current environment instead. Every tool carries the MCP readOnlyHint annotation. querypilot mcp --transport streamable-http --port 8000 serves the same tools over HTTP.
OpenAI / Anthropic tool calling:
tools = qp.as_openai_tools() # Chat Completions; qp.toolkit().openai_responses_tools() for Responses
tools = qp.as_anthropic_tools() result = qp.handle_tool_call(tool_call.name, tool_call.arguments) # dict or JSON string in, dict out
Agent frameworks:
from querypilot.integrations import (
as_langchain_tools, # LangChain / LangGraph StructuredTools as_llamaindex_tools, # LlamaIndex FunctionTools as_openai_agents_tools, # OpenAI Agents SDK FunctionTools as_claude_agent_mcp_server, # Claude Agent SDK in-process MCP server claude_agent_allowed_tools, as_functions, # plain typed functions: Pydantic AI, smolagents, CrewAI, ADK )
tools = as_langchain_tools(qp, naming="langchain") # sql_db_list_tables, sql_db_schema, sql_db_query, ...
naming="langchain" reuses the tool names from the community SQLDatabaseToolkit (no longer maintained), so existing prompts keep working. Install the matching extra: querypilot[langchain], [llamaindex], [openai-agents], [claude-agent] or [mcp]. See examples/07_frameworks.py.
Protect any Postgres client: querypilot proxy (prototype)
The proxy needs no SDK. It is a Postgres wire-protocol server that applies the same validator and access policy to every statement, whatever the client. That covers psql, psycopg, SQLAlchemy and LangChain, an existing MCP database server, Cursor or Claude Code, and BI tools. Point the client's connection string at the proxy instead of the database:
pip install "querypilot[proxy]"
querypilot proxy --upstream postgresql://readonly@db/prod --listen 127.0.0.1:6543 --policy querypilot.yaml
psql "postgresql://agent@127.0.0.1:6543/prod" -c "SELECT email FROM customers" npx -y @modelcontextprotocol/server-postgres postgresql://agent@127.0.0.1:6543/prod # unchanged MCP server
Every statement then gets the following:
- Read-only enforcement. Writes, DDL, COPY and
SETof anything outside a small allowlist are rejected. Allowed statements run in aREAD ONLYtransaction on a session that defaults to read-only, soCOMMIT; DROP TABLE …is rejected. - Row filters and the row cap. The rewritten SQL is what reaches the database, so the policy's
row_filtershold under joins, subqueries and CTEs, andLIMITis capped atmax_rows. - Masking.
masking_rulesapply by output position, soupper(email) AS contactis masked too. - Errors an agent can repair. A rejection is a normal Postgres error with a SQLSTATE, the validator's message, and a
HINT, for exampleColumn 'nope' does not exist. Columns of orders: id, customer_id, …. - Audit. One JSONL record per statement goes to
--audit-log, with the client's SQL, the SQL that ran, the row count, and the client user and application.
Driver handshakes, SET/SHOW of formatting settings, and catalog queries for psql \d and ORM reflection pass through an allowlist. Catalog queries that could read data, such as pg_stats or query_to_xml(...), are rejected. The policy file is a normal querypilot.yaml, and its database_url is used when you omit --upstream. Off loopback, set QUERYPILOT_PROXY_PASSWORD. Protocol coverage, known gaps (no TLS termination yet, no server-side cursors), and the reasons it fails closed are in docs/proxy.md.
Watch the SQL your agent already runs: querypilot trace and hooks
Some query tools can't sit behind QueryPilot, for example Palantir Foundry's MCP SQL tool. For those, QueryPilot reads what the agent did instead. trace import pairs every query tool call in Claude Code transcripts with its result. hooks install logs new calls live. trace doctor reports the failure rate by class, retry chains, latency and stalls, and says for each problem whether it is best fixed in the tool, the prompt, or the data:
querypilot trace doctor # reads ~/.claude/projects
querypilot trace doctor --output report.md # redacted, shareable querypilot hooks install --guard --max-rows 200
With --guard, a PreToolUse hook validates each query against schemas cached from the agent's own schema calls. It denies unknown columns with a "did you mean" reply before the query reaches the warehouse, blocks date arithmetic on DATE columns stored as epoch milliseconds, and enforces a row cap. Foundry's tool is mapped by default; map any other with --tool NAME=SQL_FIELD[:DIALECT]. Recovered retry chains export to eval replay as a regression suite. See docs/trace.md and the first Foundry report.
Better SQL from the model
When QueryPilot writes the SQL itself (ask, ask_database, evals), it uses the techniques with the largest measured gains in the text-to-SQL literature. The sources and numbers are in docs/research/developer-needs.md.
- Grounded schema. The prompt shows each table as compact DDL with primary keys, foreign-key join paths, comments and real values for category-like text columns: every value when there are 10 or fewer, otherwise the 3 most common. Sample values are never drawn from blocked, masked or row-filtered columns.
- Your business rules. Pass
hints=anddescriptions=toconnect(), or set them inquerypilot.yaml, for definitions such as "revenue means paid invoices only". - Pruning only when needed. Below
schema_token_budget(default 6000 tokens) the full schema is sent. Above it, QueryPilot sends the relevant tables plus the foreign-key bridge tables that join them. - A repair loop that converges. Validation errors get "did you mean" hints. Database errors are cleaned before they go back to the model. An empty result triggers one gentle review. Up to 3 attempts by default.
from querypilot import AnthropicSQLGenerator, QueryPilot
qp = QueryPilot.connect( "duckdb:///analytics.duckdb", generator=AnthropicSQLGenerator(), hints=["Revenue means SUM(amount_cents) / 100 over invoices with status = 'paid'"], descriptions={"accounts.segment": "smb, midmarket or enterprise"}, ) answer = qp.ask("Revenue by se