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.2

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.2
File Size Uploaded Provenance Actions
db_to_zod-1.0.2.tar.gz 4.1 kB Without provenance Details for db_to_zod-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 9.0 kB

Release files / db_to_zod-1.0.2.tar.gz

Download URL db_to_zod-1.0.2.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
82b0d7bd2ababb0dda56e9cb91b72301e75195d3f1331641c504cfbfb1a6fca4
BLAKE2b-256 checksum
How to use checksums
4300d5d42bfc7e4380782962e1dd7b115efcc34359aeba99f33a54f7c2b76e48
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.2-py3-none-any.whl

Download URL db_to_zod-1.0.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69a30c06f98d870b4b537955b8b4f16531420e9cef7c494990c8db463733e6a2
BLAKE2b-256 checksum
How to use checksums
49cbca540c3d983560d12316181ba1689faac4823bc64ad194c3f2d455926a81
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.2

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