According to the official website,
PlanetScale is the world’s most advanced serverless MySQL platform.
With Drizzle ORM you can access PlanetScale over http
through their official database-js
driver from serverless and serverfull environments with our drizzle-orm/planetscale-serverless package.
You can also access PlanetScale through TCP with mysql2 driver — see here.
npm
yarn
pnpm
bun
⚠️
Previously, we were suggesting the use of the connect() function from the database-js driver. However, after receiving a suggestion from the PlanetScale Team and the authors of database-js, we are now enforcing the use of the Client instance to handle connections to PlanetScale.
Please note that you will receive a warning to switch from connect() to new Client(), and starting from version 0.30.0, you will encounter an error and be required to use the Client connection. Make sure to migrate from connect() to Client
Make sure to checkout the PlanetScale official MySQL courses,
we think they’re outstanding 🙌
mysql2
According to the official website,
mysql2 is a MySQL client for Node.js with focus on performance.
Drizzle ORM natively supports mysql2 with drizzle-orm/mysql2 package.
npm
yarn
pnpm
bun
There’re two ways you can connect to the MySQL with mysql2 driver, either single client connection or a pool.
Client connection
Pool connection
⚙️
For the built in migrate function with DDL migrations we and drivers strongly encourage you to use single client connection.
For querying purposes feel free to use either client or pool based on your business demands.
TiDB Serverless
According to the official website,
TiDB Serverless is a fully-managed, autonomous DBaaS with split-second cluster provisioning and consumption-based pricing.
ℹ️
TiDB Serverless is compatible with MySQL, so you can use drizzle-orm/mysql2 to connect to it.
TiDB Serverless provides an HTTP driver for edge environments. It is natively supported by Drizzle ORM via drizzle-orm/tidb-serverless package.