Skip to content

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.

  • You have a schema.prisma and 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 pair it with @askdb/postgres (or another engine) for the actual SQL dialect at generation time.
Terminal window
npm install @askdb/prisma @askdb/introspect
# Plus the dialect you want at runtime
npm install @askdb/core @askdb/postgres @ai-sdk/openai

@askdb/prisma doesn’t bundle a SQL dialect — pair it with whichever engine package matches your runtime database.

Terminal window
# 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 writing
npx askdb introspect --engine prisma --prisma-schema ./prisma --print
# Diff against an existing schema artifact
npx askdb introspect --engine prisma --prisma-schema ./prisma --diff my-app.schema

To 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 finds prisma/schema.prisma (or schema.prisma) in your project root automatically.

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() },
);

@askdb/prisma supports any Prisma relational provider — at generation time, pair it with the matching AskDB engine adapter:

Prisma providerRuntime engine adapter
postgresql / cockroachdb@askdb/postgres
mysql@askdb/mysql
sqlite@askdb/sqlite
sqlserver@askdb/sqlserver

MongoDB is not supported — AskDB targets relational engines.

@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, supply a dialect from one of the engine packages above.