Skip to main content

Convert attrs class to CREATE TABLE command.

Project description

attrs to sql

Convert attrs class to sql CREATE TABLE command.

Usage

Define class decorated with attr.s:

@attr.s(auto_attribs=True)
class Model:
    id: int = attr.ib(metadata={"primary_key": True})
    name: str = attr.ib(metadata={"not_null": True, "length": 30})
    floats: List[float] = attr.ib(factory=list)

Run attrs_to_table with defined class:

from attrs_to_sql import attrs_to_table

attrs_to_table(Model)

Output:

CREATE TABLE public.model
(
    id int PRIMARY KEY,
    name varchar(30) NOT NULL,
    floats float[]
);

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for attrs-to-sql, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size attrs_to_sql-0.2.0-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size attrs_to_sql-0.2.0.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page