Licence
Apache-2.0
Version
0.1.0-beta.13
Deps
3
Size
58 kB
Vulns
0
Weekly
0
@askdb/sqlite
SQLite integration for AskDB. Bundles three pieces:
- Dialect — re-exports
SQLITE_DIALECTfrom@askdb/core. Passdialect: SQLITE_DIALECTtoask()to target SQLite. - Connector —
createSqliteConnector()implements theConnectorcontract from@askdb/introspectfor live introspection mode. - Catalog runner —
createSqliteCatalogQueryRunner(filePath)returns an introspection-onlyCatalogQueryRunnerbacked bybetter-sqlite3(peer dependency, lazy-loaded). Introspects viasqlite_masterandPRAGMAfunctions. Requires SQLite ≥ 3.16.
Install
pnpm add @askdb/core @askdb/introspect @askdb/sqlitebetter-sqlite3 is an optional peer dependency — install it only when using live introspection mode:
pnpm add better-sqlite3For one-off CLI introspection, include the driver in the same ephemeral command:
pnpm dlx -p askdb -p better-sqlite3 askdb introspect --engine sqlite --url ./my-database.db
npx -p askdb -p better-sqlite3 askdb introspect --engine sqlite --url ./my-database.dbUsage
NL→SQL
import { ask, loadSchema } from "@askdb/core";
import { SQLITE_DIALECT } from "@askdb/sqlite";
const schema = loadSchema("./my-app.schema");
const { sql } = await ask({
question: "How many paid orders were created last month?",
schema,
model,
dialect: SQLITE_DIALECT,
});Introspection
import { introspect } from "@askdb/introspect";
import { createSqliteConnector, createSqliteCatalogQueryRunner } from "@askdb/sqlite";
const result = await introspect(
{ mode: "live", runner: createSqliteCatalogQueryRunner("/path/to/database.db") },
{ outDir: "./my-app.schema", schemaId: "my-app" },
{ connector: createSqliteConnector() },
);Captured metadata
Tables, views, columns (SQLite affinity type strings), primary keys, unique constraints, foreign keys, and indexes. Requires SQLite ≥ 3.16 for pragma_* table-valued functions.
License
Apache-2.0 Yahya Gilany. See LICENSE and NOTICE.