Skip to content

Planetscale.MySQL reference

Source: packages/planetscale/src/MySQL/MySQLBranch.ts

A branch of a PlanetScale MySQL database.

MySQLBranch: Looking up an existing MySQL branch

Section titled “MySQLBranch: Looking up an existing MySQL branch”

MySQLBranch.lookup references a MySQL branch Alchemy doesn’t manage (created in the PlanetScale dashboard or by another stack). It is read during plan/deploy, never created, updated or deleted.

const main = Planetscale.MySQLBranch.lookup({ database: "app", name: "main" });

Source: packages/planetscale/src/MySQL/MySQLDatabase.ts

A PlanetScale MySQL (Vitess) database.

MySQLDatabase: Looking up an existing MySQL database

Section titled “MySQLDatabase: Looking up an existing MySQL database”

MySQLDatabase.lookup references a MySQL database Alchemy doesn’t manage (created in the PlanetScale dashboard or by another stack). It is read during plan/deploy, never created, updated or deleted.

const db = Planetscale.MySQLDatabase.lookup({ name: "app" });
const preview = yield* Planetscale.MySQLBranch("Preview", {
database: db,
isProduction: false,
});

Source: packages/planetscale/src/MySQL/MySQLPassword.ts

A PlanetScale password for accessing a MySQL database branch.

For PostgreSQL databases, use PostgresRole instead.

Reader password

const reader = yield* Planetscale.MySQLPassword("AppReader", {
database: "my-db",
role: "reader",
});

Writer password with TTL

const writer = yield* Planetscale.MySQLPassword("AppWriter", {
database: "my-db",
role: "writer",
ttl: 86400,
});

Admin password with IP allowlist

const admin = yield* Planetscale.MySQLPassword("Admin", {
database: "my-db",
role: "admin",
cidrs: ["203.0.113.0/24", "198.51.100.0/24"],
});