npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@deanc/kysely-schema-generator

v0.2.0

Published

A schema generator for kysely

Readme

Kysely schema generator

A very quickly hacked-together schema generator for Kysely which (currently) only supports MySQL.

Installation

With your package manager of choice install:

npm install --save @deanc/kysely-schema-generator
yarn add @deanc/kysely-schema-generator
pnpm add @deanc/kysely-schema-generator

Configuration

Either in your project root or somewhere else create a .env file with a DATABASE_URL environmental variable:

DATABASE_URL='mysql://user:password@host:3306/databaseName'

Usage

Option 1 (.env in project root and run)

kysely-schema-generator

Option 2 (.env somewhere else)

kysely-schema-generator -p /path/to/.env

Note if command can't be found you might need to use your package manager to run it (e.g. pnpm exec kysely-schema-generator)

Option 3 (write output to a file)

kysely-schema-generator -o ./kysely-db.ts

Option 4 (override database/schema name)

kysely-schema-generator -d my_database

Option 5 (include or exclude specific tables)

kysely-schema-generator -t users,orders
kysely-schema-generator -x audit_logs,temp_records

Option 6 (disable formatting)

kysely-schema-generator --no-format

Option 7 (map TINYINT(1) to boolean)

kysely-schema-generator --tinyint1-as-boolean

Options

-p, --path-env <path>           path to .env file
-o, --output <path>             write output to a file
-d, --database <name>           override database/schema name
-t, --tables <list>             comma-separated list of tables to include
-x, --exclude-tables <list>     comma-separated list of tables to exclude
    --no-format                 disable output formatting
    --tinyint1-as-boolean       map TINYINT(1) columns to boolean
-h, --help                      display help

Example Output

Given a users table:

CREATE TABLE users (
  id INT NOT NULL AUTO_INCREMENT,
  email VARCHAR(255) NOT NULL,
  status ENUM('active','inactive') NOT NULL,
  created_at TIMESTAMP NULL
)

The generator outputs:

import { Generated, Insertable, Selectable, Updateable } from 'kysely'

interface UsersTable {
  id: Generated<number>
  email: string
  status: 'active' | 'inactive'
  created_at: string | null
}
export type Users = Selectable<UsersTable>
export type NewUsers = Insertable<UsersTable>
export type UsersUpdate = Updateable<UsersTable>

export interface DB {
  users: Users
}

Integration Test (MySQL)

This test uses Testcontainers and will spin up MySQL automatically (Docker must be running).

pnpm run test:integration

Troubleshooting

  • No valid DATABASE_URL process.env found: ensure your .env file is in the path provided via --path-env, or in the project root, and contains a valid DATABASE_URL.
  • Testcontainers runtime unavailable: make sure Docker is running and accessible from your terminal.
  • Permissions errors: the MySQL user in the URL needs access to information_schema and the target database.

Limitations

  • MySQL only (no Postgres/SQLite support yet).
  • Some MySQL types may still be missing or mapped conservatively (e.g. JSON uses unknown).
  • Numeric precision/scale is not currently used to refine type output.

Development

pnpm install
pnpm test
pnpm run test:integration
pnpm run lint

Todo

(Contributions very welcome)

  • Ensure all MySQL field types are mapped correctly
  • Add support for other database engines (Postgres, SQLite at least)
  • Add test coverage
  • (Maybe) offer option to write to disk instead of relying on user to capture