Prisma
Integration · Prisma
If you already maintain a Prisma schema file, @askdb/prisma reads it directly and produces an AskDB schema artifact. No live database connection during introspection.
When to use it
Section titled “When to use it”- You have a
schema.prismaand want to skip the live-database introspection step. - You’re working in CI, on a laptop without DB access, or in an air-gapped environment.
- You pass
ask()the matchingdialectid at generation time (see Supported providers); no engine package is needed for that.
Install
Section titled “Install”For the CLI and Studio, install @askdb/prisma in your project next to askdb. askdb and @askdb/studio list it as an optional peer: they load it only to read a Prisma schema, and don’t install it, because it brings in Prisma.
npm install askdb @askdb/prisma ai zodpnpm add askdb @askdb/prisma ai zodyarn add askdb @askdb/prisma ai zodai and zod are there for Yarn Plug’n’Play: @askdb/prisma loads @askdb/core, which can only load them from your project. npx askdb@latest init --database prisma installs all of them for you. askdb also finds the copy in your project when it runs from elsewhere, as npx askdb does. To run the CLI without installing anything, name both packages in the one-off command: npx -p askdb -p @askdb/prisma askdb introspect --engine prisma.
Without it, askdb introspect --engine prisma exits 1 and names the package to install, and Studio shows the same message instead of resyncing.
To call the connector from your own code instead of the CLI:
npm install @askdb/prisma @askdb/introspect aipnpm add @askdb/prisma @askdb/introspect aiyarn add @askdb/prisma @askdb/introspect aiPlus @askdb/core and a model provider to generate SQL — for example, OpenAI:
npm install @askdb/core ai @ai-sdk/openaipnpm add @askdb/core ai @ai-sdk/openaiyarn add @askdb/core ai @ai-sdk/openai@askdb/prisma doesn’t bundle a SQL dialect. The built-in dialects live in @askdb/core: pass ask() the dialect id that matches your runtime database (see the table below). The artifact records your datasource.provider, so the CLI picks the dialect from it when askdb.config.ts sets no dialect.
CLI workflow
Section titled “CLI workflow”# Introspect a Prisma schema file (or directory of .prisma files)npx askdb introspect \ --engine prisma \ --prisma-schema ./prisma/schema.prisma \ --out my-app.schema \ --schema-id my-app
# Print the introspection result without writingnpx askdb introspect --engine prisma --prisma-schema ./prisma --print
# Diff against an existing schema artifactnpx askdb introspect --engine prisma --prisma-schema ./prisma --diff my-app.schemaTo make --prisma-schema optional on repeat runs, set introspection.providerConfig.prisma.schemaPath in askdb.config.ts — or rely on auto-discovery: with provider: "prisma" and no path configured, AskDB looks in your project root for prisma/schema.prisma, then schema.prisma, then a prisma/ directory (a multi-file schema), and uses the first it finds.
Programmatic API
Section titled “Programmatic API”import { introspect } from "@askdb/introspect";import { createPrismaConnector } from "@askdb/prisma";
await introspect( { schemaPath: "./prisma", schemaId: "my-app" }, { outDir: "my-app.schema", schemaId: "my-app" }, { connector: createPrismaConnector() },);Supported providers
Section titled “Supported providers”@askdb/prisma supports the five Prisma providers below; any other datasource.provider throws. At generation time, use the matching dialect id. To introspect the live database instead of the .prisma file, install the matching engine package:
| Prisma provider | dialect id | Engine package (live introspection) |
|---|---|---|
postgresql | "postgres" | @askdb/postgres |
cockroachdb | "cockroachdb" | none: introspect the .prisma file |
mysql | "mysql" | @askdb/mysql |
sqlite | "sqlite" | @askdb/sqlite |
sqlserver | "sqlserver" | @askdb/sqlserver |
MongoDB is not supported — AskDB targets relational engines. The @askdb/prisma reference lists the mapping with the rest of the package’s API.
What it doesn’t do
Section titled “What it doesn’t do”@askdb/prisma is a file-only connector. It does not connect to a database, it does not execute generated SQL, and it does not include a SQL dialect. For SQL generation, pass ask() the dialect id from the table above.
Read next
Section titled “Read next”© 2026 Yahya Gilany

