From ea12033eb6ce4868422eeb376c3ceca3640c411e Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 18 Nov 2025 23:13:29 +0600 Subject: [PATCH 1/3] fix: add SQLite notes --- .../02-prisma-orm/100-quickstart/200-sqlite.mdx | 13 ++++++++++--- .../200-add-to-existing-project/200-sqlite.mdx | 10 ++++++---- content/200-orm/400-tools/06-prisma-studio.mdx | 9 ++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx index 289ee857df..013b253e36 100644 --- a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx @@ -31,6 +31,10 @@ npm install prisma @types/node @types/better-sqlite3 --save-dev npm install @prisma/client @prisma/adapter-better-sqlite3 dotenv ``` +:::note[pnpm users with SQLite] +If using pnpm 10+ with `pnpx`, you'll need the [`--allow-build=better-sqlite3`](https://pnpm.io/cli/dlx#--allow-build) flag when running Prisma Studio due to SQLite's native dependency requirements. +::: + Here's what each package does: - **`prisma`** - The Prisma CLI for running commands like `prisma init`, `prisma migrate`, and `prisma generate` @@ -267,9 +271,12 @@ You should see the created user and all users printed to the console! :::note[SQLite requirements for Prisma Studio] - File paths must have a `file:` protocol right now in the database url for SQLite -- Node.js 22.5+: Works out of the box with the built-in `node:sqlite` module -- Node.js 20: Requires installing `better-sqlite3` as a dependency - - If using pnpm 10+, you'll also need to allow the `better-sqlite3` install script +- **Node.js 22.5+**: Works out of the box with the built-in `node:sqlite` module + - May require `NODE_OPTIONS=--experimental-sqlite` environment variable +- **Node.js 20**: Requires installing `better-sqlite3` as a dependency + - If using pnpm 10+ with `pnpx`, you'll need the [`--allow-build=better-sqlite3`](https://pnpm.io/cli/dlx#--allow-build) flag +- **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) +- **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet ::: diff --git a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx index 2730ac382c..ba2e319dd5 100644 --- a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx @@ -252,10 +252,12 @@ This command will: :::note[SQLite requirements for Prisma Studio] - File paths must have a `file:` protocol right now in the database url for SQLite -- Node.js 22.5+: Works out of the box with the built-in `node:sqlite` module -- Node.js 20: Requires installing `better-sqlite3` as a dependency - - If using pnpm 10+, you'll also need to allow the `better-sqlite3` install script - +- **Node.js 22.5+**: Works out of the box with the built-in `node:sqlite` module + - May require `NODE_OPTIONS=--experimental-sqlite` environment variable +- **Node.js 20**: Requires installing `better-sqlite3` as a dependency + - If using pnpm 10+ with `pnpx`, you'll need the [`--allow-build=better-sqlite3`](https://pnpm.io/cli/dlx#--allow-build) flag +- **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) +- **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet ::: ## Next steps diff --git a/content/200-orm/400-tools/06-prisma-studio.mdx b/content/200-orm/400-tools/06-prisma-studio.mdx index 95832603ab..60e2f4470f 100644 --- a/content/200-orm/400-tools/06-prisma-studio.mdx +++ b/content/200-orm/400-tools/06-prisma-studio.mdx @@ -134,9 +134,12 @@ Prisma Studio currently supports the following databases: PostgreSQL, MySQL, and ### SQLite requirements for Prisma Studio - File paths must have a `file:` protocol right now in the database url for SQLite -- Node.js 22.5+: Works out of the box with the built-in `node:sqlite` module -- Node.js 20: Requires installing `better-sqlite3` as a dependency - - If using pnpm 10+, you'll also need to allow the `better-sqlite3` install script +- **Node.js 22.5+**: Works out of the box with the built-in `node:sqlite` module + - May require `NODE_OPTIONS=--experimental-sqlite` environment variable +- **Node.js 20**: Requires installing `better-sqlite3` as a dependency + - If using pnpm 10+ with `pnpx`, you'll need the [`--allow-build=better-sqlite3`](https://pnpm.io/cli/dlx#--allow-build) flag +- **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) +- **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet ### Databases not yet supported From 4c55afb044a4c94c1d754871ca393e9fac810020 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 18 Nov 2025 23:21:21 +0600 Subject: [PATCH 2/3] fix: update serverless driver doc --- .../300-database/750-serverless-driver.mdx | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/content/250-postgres/300-database/750-serverless-driver.mdx b/content/250-postgres/300-database/750-serverless-driver.mdx index 7911abfdd7..6423a1c290 100644 --- a/content/250-postgres/300-database/750-serverless-driver.mdx +++ b/content/250-postgres/300-database/750-serverless-driver.mdx @@ -150,18 +150,39 @@ With 100ms network latency, 3 sequential queries take 300ms (3 x RTT), but pipel ### Parameter streaming -Parameters over 1KB are automatically streamed without buffering in memory: +Parameters over 1KB are automatically streamed without buffering in memory. For large binary parameters, you must use `boundedByteStreamParameter()` which creates a `BoundedByteStreamParameter` object that carries the total byte size, required by the PostgreSQL protocol: ```ts -// Large text content (e.g., 10MB document) -const largeDocument = generateLargeText() +import { client, defaultClientConfig, boundedByteStreamParameter, BINARY } from "@prisma/ppg" + +const cl = client(defaultClientConfig(process.env.PRISMA_DIRECT_TCP_URL!)) + +// Large binary data (e.g., file content) +const stream = getReadableStream() // Your ReadableStream source +const totalSize = 1024 * 1024 // Total size must be known in advance + +// Create a bounded byte stream parameter +const streamParam = boundedByteStreamParameter(stream, BINARY, totalSize) // Automatically streamed - constant memory usage -await ppg.sql.exec` - INSERT INTO documents (content) VALUES (${largeDocument}) -` +await cl.query("INSERT INTO files (data) VALUES ($1)", streamParam) ``` +For `Uint8Array` data, use `byteArrayParameter()`: + +```ts +import { client, defaultClientConfig, byteArrayParameter, BINARY } from "@prisma/ppg" + +const cl = client(defaultClientConfig(process.env.PRISMA_DIRECT_TCP_URL!)) + +const bytes = new Uint8Array([1, 2, 3, 4]) +const param = byteArrayParameter(bytes, BINARY) + +await cl.query("INSERT INTO files (data) VALUES ($1)", param) +``` + +The `boundedByteStreamParameter()` function is provided by the `@prisma/ppg` library and requires the total byte size to be known in advance due to PostgreSQL protocol requirements. + ### Transactions and batch operations Transactions automatically handle BEGIN, COMMIT, and ROLLBACK: From 8d37de9493aeefb3de9725b8d57972868c1f46aa Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 18 Nov 2025 23:33:49 +0600 Subject: [PATCH 3/3] feat: add callout --- .../02-prisma-orm/100-quickstart/200-sqlite.mdx | 13 +++++++++++++ .../200-add-to-existing-project/200-sqlite.mdx | 14 ++++++++++++++ content/200-orm/400-tools/06-prisma-studio.mdx | 15 +++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx index 013b253e36..71006ab8cf 100644 --- a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx @@ -278,6 +278,19 @@ You should see the created user and all users printed to the console! - **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) - **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet +:::tip[Using `npx` with `better-sqlite3`] + +If you don't have `node:sqlite` available in your runtime or prefer not to install `better-sqlite3` as a hard dependency (it adds ~10MB), you can use `npx` to temporarily install the required packages: + +```terminal +npx -p better-sqlite3 -p prisma prisma studio --url file:./dev.db +``` + +This command: +- Temporarily installs `better-sqlite3` without adding it to your project dependencies +- Runs Prisma Studio with the specified SQLite database file +- Avoids the 10MB overhead of `better-sqlite3` in your project + ::: ## Next steps diff --git a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx index ba2e319dd5..fbdafa6a4d 100644 --- a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx @@ -258,6 +258,20 @@ This command will: - If using pnpm 10+ with `pnpx`, you'll need the [`--allow-build=better-sqlite3`](https://pnpm.io/cli/dlx#--allow-build) flag - **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) - **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet + +:::tip[Using `npx` with `better-sqlite3`] + +If you don't have `node:sqlite` available in your runtime or prefer not to install `better-sqlite3` as a hard dependency (it adds ~10MB), you can use `npx` to temporarily install the required packages: + +```terminal +npx -p better-sqlite3 -p prisma prisma studio --url file:./path/to/your/database.db +``` + +This command: +- Temporarily installs `better-sqlite3` without adding it to your project dependencies +- Runs Prisma Studio with the specified SQLite database file +- Avoids the 10MB overhead of `better-sqlite3` in your project + ::: ## Next steps diff --git a/content/200-orm/400-tools/06-prisma-studio.mdx b/content/200-orm/400-tools/06-prisma-studio.mdx index 60e2f4470f..b54aff4053 100644 --- a/content/200-orm/400-tools/06-prisma-studio.mdx +++ b/content/200-orm/400-tools/06-prisma-studio.mdx @@ -141,6 +141,21 @@ Prisma Studio currently supports the following databases: PostgreSQL, MySQL, and - **Deno >= 2.2**: Supported via [built-in SQLite module](https://docs.deno.com/api/node/sqlite/) - **Bun**: Support for Prisma Studio with SQLite is coming soon and is not available yet +:::tip[Using `npx` with `better-sqlite3`] + +If you don't have `node:sqlite` available in your runtime or prefer not to install `better-sqlite3` as a hard dependency (it adds ~10MB), you can use `npx` to temporarily install the required packages: + +```terminal +npx -p better-sqlite3 -p prisma prisma studio --url file:./my_file.db +``` + +This command: +- Temporarily installs `better-sqlite3` without adding it to your project dependencies +- Runs Prisma Studio with the specified SQLite database file +- Avoids the 10MB overhead of `better-sqlite3` in your project + +::: + ### Databases not yet supported Support for CockroachDB and MongoDB is not currently available but may be added in future releases. If you're using these databases: