Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -206,6 +206,12 @@ const prisma = new PrismaClient({ adapter })
export { prisma }
```

:::tip

If you need to query your database via HTTP from an edge runtime (Cloudflare Workers, Vercel Edge Functions, etc.), use the [Prisma Postgres serverless driver](/postgres/database/serverless-driver#use-with-prisma-orm).

:::

## 8. Write your first query

Create a `script.ts` file to test your setup:
Expand Down Expand Up @@ -274,3 +280,4 @@ You should see the created user and all users printed to the console!
- [Prisma Postgres documentation](/postgres)
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database connection management](/orm/prisma-client/setup-and-configuration/databases-connections)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ const prisma = new PrismaClient({ adapter })
export { prisma }
```

:::tip

If you need to query your database via HTTP from an edge runtime (Cloudflare Workers, Vercel Edge Functions, etc.), use the [Prisma Postgres serverless driver](/postgres/database/serverless-driver#use-with-prisma-orm).

:::

## 8. Query your database

Now you can use Prisma Client to query your database. Create a `script.ts` file:
Expand Down Expand Up @@ -256,3 +262,4 @@ This command will:
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database introspection](/orm/prisma-schema/introspection)
- [Prisma Migrate](/orm/prisma-migrate)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ const prisma = new PrismaClient({ adapter })
export { prisma }
```

:::tip

If you need to query your database via HTTP from an edge runtime (Cloudflare Workers, Vercel Edge Functions, etc.), use the [Prisma Postgres serverless driver](/postgres/database/serverless-driver#use-with-prisma-orm).

:::

### 4.2. Write your first query

Paste the following boilerplate into `index.ts`:
Expand Down Expand Up @@ -565,7 +571,7 @@ This time, you're seeing two `User` objects being printed. Both of them have a `

## Next steps

You just got your feet wet with a basic Prisma Postgres setup. If you want to explore more complex queries, such as adding caching functionality, check out the official [Quickstart](/getting-started/prisma-orm/quickstart/prisma-postgres).
You just got your feet wet with a basic Prisma Postgres setup. If you want to explore more complex queries, such as [adding caching functionality](/postgres/database/caching#setting-up-caching-in-prisma-postgres), check out the official [Quickstart](/getting-started/prisma-orm/quickstart/prisma-postgres).

### View and edit data in Prisma Studio

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ const prisma = new PrismaClient({ adapter })
export { prisma }
```

:::tip

If you need to query your database via HTTP from an edge runtime (Cloudflare Workers, Vercel Edge Functions, etc.), use the [Prisma Postgres serverless driver](/postgres/database/serverless-driver#use-with-prisma-orm).

:::

## 8. Write your first query

Create a `script.ts` file to test your setup:
Expand Down Expand Up @@ -251,3 +257,4 @@ You should see the created user and all users printed to the console!
- [Prisma Postgres documentation](/postgres)
- [Prisma Config reference](/orm/reference/prisma-config-reference)
- [Database connection management](/orm/prisma-client/setup-and-configuration/databases-connections)
- [Cache your queries](/postgres/database/caching#setting-up-caching-in-prisma-postgres)
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ You can connect to your database using a Node.js-based driver from Prisma Client

- PostgreSQL
- [`pg`](/orm/overview/databases/postgresql#using-the-node-postgres-driver)
- Prisma Postgres
- [`@prisma/adapter-ppg`](/postgres/database/serverless-driver#use-with-prisma-orm)
- MySQL/MariaDB
- [`mariadb`](/orm/overview/databases/mysql#using-the-mariadb-driver)
- SQLite
Expand All @@ -65,6 +67,7 @@ You can connect to your database using a Node.js-based driver from Prisma Client
Database providers, such as Neon and PlanetScale, allow you to connect to your database using other protocols besides TCP, such as HTTP and WebSockets. These database drivers are optimized for connecting to your database in serverless and edge environments.

Prisma ORM maintains the following serverless driver adapters:
- [Prisma Postgres](/postgres/database/serverless-driver#use-with-prisma-orm)
- [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm) (and Vercel Postgres)
- [PlanetScale](/orm/overview/databases/planetscale#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview)
- [Cloudflare D1](/orm/overview/databases/cloudflare-d1)
Expand All @@ -79,6 +82,7 @@ You can also build your own driver adapter for the database you're using. The fo

Refer to the following pages to learn more about how to use the specific driver adapters with the specific database providers:
- [PostgreSQL](/orm/overview/databases/postgresql#using-the-node-postgres-driver)
- [Prisma Postgres](/postgres/database/serverless-driver#use-with-prisma-orm)
- [MySQL/MariaDB](/orm/overview/databases/mysql#using-the-mariadb-driver)
- [MS SQL Server](/orm/overview/databases/sql-server#using-the-node-mssql-driver)
- [Neon](/orm/overview/databases/neon#how-to-use-neons-serverless-driver-with-prisma-orm)
Expand Down Expand Up @@ -146,6 +150,19 @@ const prisma = new PrismaClient({ adapter })

See the docs for the driver adapter you're using for concrete setup instructions.

:::tip[Tuning pool sizes, timeouts, or other connection parameters]

See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for the Prisma ORM v7 driver adapter defaults and how they map from Prisma ORM v6 URL parameters.

:::

:::tip[Prisma timeouts]

Prisma ORM also has its own configurable timeouts that are separate from the database driver timeouts. If you see a timeout error and are unsure whether it comes from the driver or from Prisma Client, see the [Prisma Client timeouts and transaction options documentation](/orm/prisma-client/queries/transactions#transaction-options).

:::


### Driver adapters and custom output paths

In Prisma ORM 7, the recommended approach is to use a custom output path for Prisma Client. The default output path is `../generated/prisma`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The following arguments can be used:
| Argument name | Required | Default | Description |
| :--------------------- | :------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `schema` | **Yes** | `public` | Name of the [schema](https://www.postgresql.org/docs/12/ddl-schemas.html) you want to use, e.g. `myschema` |
| `connection_limit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) |
| `connection_limit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) (Prisma ORM v6 and before) |
| `connect_timeout` | No | `5` | Maximum number of seconds to wait for a new connection to be opened, `0` means no timeout |
| `pool_timeout` | No | `10` | Maximum number of seconds to wait for a new connection from the pool, `0` means no timeout |
| `sslmode` | No | `prefer` | Configures whether to use TLS. Possible values: `prefer`, `disable`, `require` |
Expand All @@ -160,6 +160,10 @@ As an example, if you want to connect to a schema called `myschema`, set the con
postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=myschema&connection_limit=5&socket_timeout=3
```

:::tip[Prisma ORM v7 connection pooling]
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `pg`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
:::

### Configuring an SSL connection

You can add various parameters to the connection URL if your database server uses SSL. Here's an overview of the possible parameters:
Expand Down
6 changes: 5 additions & 1 deletion content/200-orm/050-overview/500-databases/400-mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The following arguments can be used:

| Argument name | Required | Default | Description |
| :----------------- | :------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `connection_limit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) |
| `connection_limit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) (Prisma ORM v6 and before) |
| `connect_timeout` | No | `5` | Maximum number of seconds to wait for a new connection to be opened, `0` means no timeout |
| `pool_timeout` | No | `10` | Maximum number of seconds to wait for a new connection from the pool, `0` means no timeout |
| `sslcert` | No | | Path to the server certificate. Certificate paths are [resolved relative to the `./prisma folder`](/orm/prisma-schema/overview/data-sources#securing-database-connections) |
Expand All @@ -130,6 +130,10 @@ As an example, if you want to set the connection pool size to `5` and configure
mysql://USER:PASSWORD@HOST:PORT/DATABASE?connection_limit=5&socket_timeout=3
```

:::tip[Prisma ORM v7 connection pooling]
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `mariadb`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
:::

### Configuring an SSL connection

You can add various parameters to the connection URL if your database server uses SSL. Here's an overview of the possible parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sqlserver://HOST[:PORT];database=DATABASE;user={MyServer/MyUser};password={ThisI
| <ul><li>`password`</li><li>`pwd`</li></ul> | No - see Comments | | Password for SQL Server login _or_ Windows (Active Directory) username if `integratedSecurity` is set to `true` (Windows only). |
| `encrypt` | No | `true` | Configures whether to use TLS all the time, or only for the login procedure, possible values: `true` (use always), `false` (only for login credentials). |
| `integratedSecurity` | No | | Enables [Windows authentication (integrated security)](https://learn.microsoft.com/en-us/previous-versions/dotnet/framework/data/adonet/sql/authentication-in-sql-server), possible values: `true`, `false`, `yes`, `no`. If set to `true` or `yes` and `username` and `password` are present, login is performed through Windows Active Directory. If login details are not given via separate arguments, the current logged in Windows user is used to login to the server. |
| `connectionLimit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) |
| `connectionLimit` | No | `num_cpus * 2 + 1` | Maximum size of the [connection pool](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) (Prisma ORM v6 and before) |
| `connectTimeout` | No | `5` | Maximum number of seconds to wait for a new connection |
| `schema` | No | `dbo` | Added as a prefix to all the queries if schema name is not the default. |
| <ul><li>`loginTimeout`</li><li>`connectTimeout`</li><li>`connectionTimeout`</li></ul> | No | | Number of seconds to wait for login to succeed. |
Expand All @@ -131,6 +131,10 @@ sqlserver://HOST[:PORT];database=DATABASE;user={MyServer/MyUser};password={ThisI
| `trustServerCertificate` | No | `false` | Configures whether to trust the server certificate. |
| `trustServerCertificateCA` | No | | A path to a certificate authority file to be used instead of the system certificates to authorize the server certificate. Must be either in `pem`, `crt` or `der` format. Cannot be used together with `trustServerCertificate` parameter. |

:::tip[Prisma ORM v7 connection pooling]
In Prisma ORM v7, [driver adapters](/orm/overview/databases/database-drivers) are the default for relational databases. Connection pooling is handled by the Node.js driver you provide (like `mssql`), not by Prisma's connection URL parameters. See the [connection pool guide](/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool) for v7 defaults and configuration.
:::

### Using [integrated security](https://learn.microsoft.com/en-us/previous-versions/dotnet/framework/data/adonet/sql/authentication-in-sql-server) (Windows only)

The following example uses the currently logged in Windows user to log in to Microsoft SQL Server:
Expand Down
Loading
Loading