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.

Source Distribution

attrs_to_sql-0.0.3.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

attrs_to_sql-0.0.3-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page