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.

npm install zod-dbs-mysql
INSTALL
IMPORT
SIG · ZOD-DBS-MYSQL
Z
zod-dbs-mysql
databasejavascriptv1.0.5
harness data pending
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
import { createProvider } from 'zod-dbs-mysql'
import createProvider from 'zod-dbs-mysql'
createProvider is a named export, not default.
generateZodSchemas
import { generateZodSchemas } from 'zod-dbs'
import { generateZodSchemas } from 'zod-dbs-mysql'
generateZodSchemas comes from 'zod-dbs', not the provider package.
zod-dbs-cli usage with provider
npx zod-dbs --provider mysql
npx zod-dbs-mysql
CLI is run via zod-dbs; --provider mysql selects the mysql provider.

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 issues
gotchaPackage has a peer dependency on mysql2 >=2 which must be installed separately. Failure to install mysql2 results in runtime errors.
fix
Install mysql2: npm install mysql2
affects: >=1.0
gotchaThe provider only introspects tables and columns. Views, stored procedures, or functions are not supported.
fix
For views, consider manual schema definitions or feature request.
affects: >=1.0
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.
fix
Use --schema-name option in CLI or schemaName in programmatic config.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
Peer dependency mysql2 not installed.
fix
npm install mysql2
Error: getaddrinfo ENOTFOUND localhost
MySQL host not reachable (defaults to localhost).
fix
Provide correct host via connection-string or --host option.
Error: ER_DBACCESS_DENIED_ERROR: Access denied for user 'user'@'host' to database 'db'
Incorrect credentials or insufficient privileges.
fix
Verify username, password, and database permissions.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
mysql2requiredRequired for database connectivity (peer dependency)
Agent activity
36 hits · last 30 days
node
34
Resources
zod-dbs-mysql — npm install zod-dbs-mysql · libregistry