PostgreSQL CREATE TABLE to Pydantic model
Paste a PostgreSQL CREATE TABLE and get a Pydantic v2 BaseModel. Nullable columns become Optional, NUMERIC maps to Decimal (not float, which corrupts money math), and timestamps become datetime.
The fields come from your real DDL, so the model matches the table you have. Runs on the server and is discarded after the response.
Example
CREATE TABLE product (
id BIGSERIAL PRIMARY KEY,
sku VARCHAR(40) UNIQUE NOT NULL,
name VARCHAR(200) NOT NULL,
price NUMERIC(12, 2) NOT NULL,
in_stock BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
from datetime import datetime
from decimal import Decimal
from pydantic import BaseModel
class Product(BaseModel):
id: int
sku: str
name: str
price: Decimal
in_stock: bool
created_at: datetime