Registry / database / zod-dbs-mysql

zod-dbs-mysql

JSON →
library1.0.5jsnpmunverified

MySQL provider for zod-dbs, enabling type-safe database schema generation from MySQL or MariaDB databases. Current stable version is 1.0.5 with regular updates. It uses mysql2 for connectivity and introspects via information_schema.columns, supporting both MySQL and MariaDB. Key differentiator: integrates with zod-dbs to generate Zod schemas directly from database schema, providing end-to-end type safety without manual schema definitions.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createProvider is a named export, not default.

import { createProvider } from 'zod-dbs-mysql'

generateZodSchemas comes from 'zod-dbs', not the provider package.

import { generateZodSchemas } from 'zod-dbs'

CLI is run via zod-dbs; --provider mysql selects the mysql provider.

npx zod-dbs --provider mysql

Generates Zod schemas from a MySQL database using the zod-dbs-mysql provider.

// Install dependencies: // npm install zod-dbs zod-dbs-mysql mysql2 import { generateZodSchemas } from 'zod-dbs'; import { createProvider } from 'zod-dbs-mysql'; const provider = createProvider({ connectionString: process.env.MYSQL_CONNECTION_STRING ?? 'mysql://root:password@localhost:3306/mydb' }); await generateZodSchemas({ provider, config: { output: './src/schemas', generateEnums: true } });
Debug
Known footguns
gotchaPackage has a peer dependency on mysql2 >=2 which must be installed separately. Failure to install mysql2 results in runtime errors.
gotchaThe provider only introspects tables and columns. Views, stored procedures, or functions are not supported.
gotchaSchema name may need to be explicitly provided when using multiple databases or when the database name differs from schema name. Not providing schema-name can lead to missing tables.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
6 hits · last 30 days
gptbot
3
Resources