MySQL and MariaDB Driver Adapters
Prisma ORM provides a driver adapter for MySQL and MariaDB databases using the official MariaDB connector.MariaDB Adapter
The@prisma/adapter-mariadb package enables usage of the mariadb driver with Prisma ORM. This driver works with both MariaDB and MySQL databases.
Installation
Usage
Configuration Options
The adapter accepts MariaDB connection configuration:Connection String
Alternatively, you can use a connection string:Connection Pool Management
The MariaDB driver automatically manages connection pooling:Transaction Support
The adapter supports all transaction features:Isolation Levels
Supported isolation levels:READ UNCOMMITTEDREAD COMMITTEDREPEATABLE READ(default for MySQL/MariaDB)SERIALIZABLE
Savepoints
The adapter supports nested transactions using savepoints:Error Handling
The adapter maps MySQL/MariaDB errors to Prisma error codes:| MySQL Error | Prisma Code | Description |
|---|---|---|
| 1062 | P2002 | Unique constraint violation |
| 1452 | P2003 | Foreign key constraint violation |
| 1048 | P2011 | Null constraint violation |
| 1406 | P2000 | Value too long for column |
| 2002 | P1001 | Can’t reach database server |
| 1045 | P1000 | Authentication failed |
Cloud Database Support
The adapter works with cloud-hosted MySQL/MariaDB databases:AWS RDS
Google Cloud SQL
Azure Database for MySQL
Performance Tips
-
Connection Pooling: Set appropriate pool size based on your workload
-
Timeout Configuration: Configure timeouts for your environment
- Prepared Statements: The driver uses prepared statements by default for better performance
Limitations
- The adapter requires the
mariadbnpm package version 3.4.5 or later - Some MariaDB-specific features may not be available when connecting to MySQL