Skip to main content

db-to-zod

Generate TypeScript types and Zod schemas from SQL CREATE TABLE statements.

pip install db-to-zod
db-to-zod schema.sql -o schema.ts

Input

CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    email VARCHAR(255) NOT NULL,
    full_name TEXT,
    created_at DATETIME NOT NULL
);

Output

import { z } from 'zod';

export const UsersSchema = z.object({
  id: z.number().int(),
  email: z.string(),
  full_name: z.string().nullable().optional(),
  created_at: z.string().datetime(),
});

export type Users = z.infer<typeof UsersSchema>;

What it handles

  • CREATE TABLE [IF NOT EXISTS] for SQLite / PostgreSQL / MySQL-style DDL
  • Common types: INTEGER/INT/BIGINT, REAL/FLOAT/DOUBLE/NUMERIC, TEXT/VARCHAR/CHAR, BOOLEAN, DATETIME/TIMESTAMP, JSON, BLOB
  • NOT NULL and PRIMARY KEY -> required; otherwise .nullable().optional()

Limitations (v1)

  • One column definition per line is expected
  • No enums, arrays, CHECK constraints, defaults or foreign-key awareness
  • Unknown types fall back to z.string()
  • Reads .sql files only; it does not connect to a database

MIT licensed. Issues and PRs welcome.

Metadata

Release files for db-to-zod 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for db-to-zod 1.0.1
File Size Uploaded Provenance Actions
db_to_zod-1.0.1.tar.gz 3.9 kB Without provenance Details for db_to_zod-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for db-to-zod 1.0.1
File Interpreter ABI Platform Actions
db_to_zod-1.0.1-py3-none-any.whl Python 3 none any Details for db_to_zod-1.0.1-py3-none-any.whl

Total release size: 8.8 kB

Release files / db_to_zod-1.0.1.tar.gz

Download URL db_to_zod-1.0.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9e73a22286b89bb6141488ad5c9bdb701c1eb1a5537b0b9de256cf84e2f1e3a3
BLAKE2b-256 checksum
How to use checksums
d6d3fb0265e9eda9bc68fd3f21fd770bcfc4b48ff70b6741bd50961c683cec5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / db_to_zod-1.0.1-py3-none-any.whl

Download URL db_to_zod-1.0.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10bef5a46a1ef3980b6faca711ebd7333242b530df5175d91d0866653b9c659a
BLAKE2b-256 checksum
How to use checksums
f47550d08bf9d9f4ee144951a2a523ce2d100a3d2d63f89c2272374a8e419089
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for db-to-zod 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page