Schemint

paste PostgreSQL or JSON, get your schema reviewed like a senior would

PostgreSQL CREATE TABLE to Rust struct (serde)

Paste a CREATE TABLE, get a serde struct. Nothing you paste is stored.

Paste a PostgreSQL CREATE TABLE and get a Rust struct with serde derives. Nullable columns become Option<T>, NUMERIC maps to String (no stdlib decimal; f64 corrupts money math and rust_decimal is a crate decision that stays yours), and reserved words like a type column come out escaped as r#type.

Mapped from your real DDL, on the server, discarded after the response.

Try it on your own schema

Example

PostgreSQL in:

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()
);

Generated:

product.rs

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct Product {
    pub id: i64,
    pub sku: String,
    pub name: String,
    pub price: String,
    pub in_stock: bool,
    pub created_at: String,
}

Related