Skip to content

The open-source Text-to-SQL toolkit
your data team trusts.

Ask your data. Keep control. AskDB turns natural-language questions into reviewed SQL your app runs — your schema, your model, your database. The toolkit handles the SQL so your team can focus on the business context, not the plumbing.

Install AskDB

$ npx askdb init

# OR: npm install askdb

Next: Quickstart Install options GitHub

Postgres · MySQL · SQLite · SQL ServerOpen source · Apache 2.0No data leaves your stack

Your data never touches the model

AskDB sends the question and your schema artifact — never your rows, your credentials, or your query results. The model writes SQL blind to your data.

Reviewed schema, your app runs the SQL

Your team authors and reviews the schema context. AskDB returns SQL — your application chooses whether to log it, approve it, or run it.

Safety guardrails on every query

Every generated query is parsed, scoped, and rejected if it violates the rules your schema declares — read-only, tenant filters, sensitive columns.

You own the infrastructure and the context

AskDB is a library you wire into your stack. Your model key, your database, your vector store. The schema artifact is a file you commit, not a black box.

  1. Init

    Run askdb init to scaffold askdb.config.ts — your provider, database, and model settings, checked in like code.

  2. Introspect

    AskDB reads your database (or a Prisma schema file) into a schema artifact: tables, columns, types, and relationships on disk.

  3. Enrich

    In Studio, add the descriptions, aliases, business concepts, and sensitive markers that make generation reliable. Test questions as you go.

  4. Use

    Call ask() from your app — or POST to the HTTP API. AskDB returns validated SQL; your application logs it, approves it, and runs it through your own pool.

A few lines of TypeScript: load a schema, ask a question, run the SQL through your own connection pool.

import { ask, loadSchema } from "@askdb/core";
import { openai } from "@ai-sdk/openai";
import { Pool } from "pg";
const schema = await loadSchema("./my-app.schema");
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const { sql } = await ask({
question: "Which customers signed up last week?",
schema,
dialect: "postgres",
model: openai("gpt-4o-mini"),
});
// Log or approve `sql` here, then run it through your own pool.
const result = await pool.query(sql);

PostgreSQL

@askdb/postgres

Reference dialect — new features land here first.

MySQL

@askdb/mysql

First-class dialect and introspection.

SQLite

@askdb/sqlite

First-class dialect — embedded and file-backed, great for dev and tests.

SQL Server

@askdb/sqlserver

First-class T-SQL dialect and introspection.

What the model sees — and what it doesn’t

Section titled “What the model sees — and what it doesn’t”
The model sees

What crosses the boundary

  • The user's question
  • Your schema artifact (tables, columns, descriptions you authored)
  • Reasoning and SQL it generates
Stays in your stack

What never leaves

  • Your database rows
  • Database credentials and connection strings
  • Query results returned to your app
  • User identifiers, session tokens, anything you don't put in the prompt