Generates TypeScript type definitions from a MySQL database schema. v2.1.0, active development, requires Node >=18.3. Automatically converts snake_case table names to PascalCase types, supports custom suffix, column type overrides, enum string generation, and tinyint-as-boolean toggle. Outputs per-table files with index re-export or single file. Useful for Knex or raw MySQL users who want typed database schemas without an ORM. Alternatives like mysql-type-defs-generator exist but this package offers a more focused API and CLI with minimal configuration.
npm install mysql-types-generatorVerified import paths — ran on the pinned version, not inferred.
Generates TypeScript types from a MySQL database, outputting each table as a PascalCase type with 'PO' suffix in separate files.
Ensure the output directory is dedicated; back up any existing files.
Use syntax: npx mysql-types-generator --outFile types.ts mydb
Rename tables to snake_case or use overrides to manually map types.
Use only 'uri' or the individual fields, not both.
Ensure 'mysql-types-generator' is installed with all dependencies: npm install mysql-types-generator
Verify MySQL is running on port 3306, check host/port/credentials.
Use import statement: import { generateMysqlTypes } from 'mysql-types-generator'Use named import: import { generateMysqlTypes } from 'mysql-types-generator'