Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions content/200-orm/400-tools/06-prisma-studio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 27 additions & 6 deletions content/250-postgres/300-database/750-serverless-driver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading