Skip to main content

PydSQL

PyPI version Python versions Build Coverage Contributing License Downloads

A lightweight Python utility to generate SQL CREATE TABLE statements directly from your Pydantic models.


What is PydSQL?

PydSQL is a focused developer tool that bridges the gap between your Pydantic data models and your SQL database schema. It reads your Pydantic model and automatically generates a corresponding CREATE TABLE statement, saving time and preventing manual errors.

PydSQL is not a full ORM like SQLAlchemy. It’s a lightweight utility for developers who want to write their own SQL but hate repetitive schema definitions.


Why Does it Exist?

While ORMs are powerful, they can be overkill for small projects or prototypes. Without an ORM, manually writing CREATE TABLE statements is error-prone and can drift out of sync with Pydantic models. PydSQL automates this tedious part while leaving you in full control.


Installation

Install directly from PyPI:

pip install pydsql

Or install from source:

git clone https://github.com/pranavkp71/PydSQL.git
cd PydSQL
pip install .

Usage

Single model

from pydantic import BaseModel
from pydsql.generator import generate_create_table_statement
from datetime import date

class Product(BaseModel):
    product_id: int
    name: str
    price: float
    launch_date: date
    is_available: bool

sql = generate_create_table_statement(Product)
print(sql)

Output

CREATE TABLE product (
    product_id INTEGER,
    name TEXT,
    price REAL,
    launch_date DATE,
    is_available BOOLEAN
);

Multiple models

from pydsql.generator import generate_create_table_statement

# Assuming Product and AnotherModel are defined Pydantic models
models = [Product, AnotherModel]

for model in models:
    print(generate_create_table_statement(model))

Features

  • Automatic schema generation: Convert Pydantic models to SQL CREATE TABLE statements.
  • Basic types supported: int, str, float, bool, date.
  • Lightweight and ORM-free: Designed for developers who prefer writing SQL.
  • Pydantic v2 compatible: Works with modern Pydantic versions.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for setup, testing, linting, and pull request guidelines.


License

MIT

Metadata

Release files for pydsql 0.1.4

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

Source distribution (sdist)

Source distribution for pydsql 0.1.4
File Size Uploaded Provenance Actions
pydsql-0.1.4.tar.gz 4.1 kB Without provenance Details for pydsql-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydsql 0.1.4
File Interpreter ABI Platform Actions
pydsql-0.1.4-py3-none-any.whl Python 3 none any Details for pydsql-0.1.4-py3-none-any.whl

Total release size: 8.2 kB

Release files / pydsql-0.1.4.tar.gz

Download URL pydsql-0.1.4.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8977fc8498d35af4a0c8b01693cd507f87d3d5b6b8855c4bfcd1133f678031d8
BLAKE2b-256 checksum
How to use checksums
f4496d7f25fabe5bd32de716bb96c084eae8b585d74e5517decb70e6b7c6b387
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / pydsql-0.1.4-py3-none-any.whl

Download URL pydsql-0.1.4-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf3b1865aba935f3a8781a246a9eeb83225bd710fc0ae185fad1ee5578c94aaa
BLAKE2b-256 checksum
How to use checksums
41d63869e6c8c3a2c79e5c235beb85f913ebf31f47b340e35aa2940445630047
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Security for pydsql 0.1.4

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