Overview
Thedatasource block defines the database connection configuration for your Prisma schema. Each Prisma schema requires exactly one datasource block.
Basic Syntax
Supported Providers
Prisma supports the following database providers:PostgreSQL
MySQL
SQLite
SQL Server
MongoDB
CockroachDB
Provider Extensions
PostgreSQL supports database extensions that can be enabled in your schema:citext- Case-insensitive text typepostgis- Geographic objects supportuuid-ossp- UUID generation functionspgcrypto- Cryptographic functions
Naming Conventions
The datasource block requires:- A unique name identifier (commonly
db) - The
providerfield specifying the database type
Multiple Database Support
While Prisma schemas typically use a single datasource, you can reference it consistently throughout your models:Best Practices
- Use descriptive names for your datasource (typically
dbordatabase) - Choose the provider that matches your production database
- Enable only necessary PostgreSQL extensions
- Keep datasource configuration in your schema file for version control