Setup & configuration
This section describes how to set up, generate, configure, and instantiate PrismaClient
, as well as when and how to actively manage connections.
In this section
Introduction
Prisma Client is an auto-generated and type-safe query builder that's tailored to your data. The easiest way to get started with Prisma Client is by following the Quickstart.
Generating Prisma Client
Prisma Client is an auto-generated database client that's tailored to your database schema. By default, Prisma Client is generated into the node_modules/.prisma/client folder, but you can specify a custom location.
Instantiating Prisma Client
The following example demonstrates how to import and instantiate your generated client from the default path:
Database connections
Custom model and field names
The Prisma Client API is generated based on the models in your Prisma schema. Models are typically 1:1 mappings of your database tables.
Configuring error formatting
By default, Prisma Client uses ANSI escape characters to pretty print the error stack and give recommendations on how to fix a problem. While this is very useful when using Prisma Client from the terminal, in contexts like a GraphQL API, you only want the minimal error without any additional formatting.
Read replicas
Read replicas enable you to distribute workloads across database replicas for high-traffic workloads. The read replicas extension, @prisma/extension-read-replicas, adds support for read-only database replicas to Prisma Client.
Database polyfills
Prisma Client provides features that are typically either not achievable with particular databases or require extensions. These features are referred to as polyfills. For all databases, this includes: