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.2.0.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for attrs_to_sql-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb1cedc552e639818ad2360a677c6a904c4a598778261f9c8ac4c50b78b90b7c |
|
MD5 | 48ddf6310202f8ee0181df9e66202d12 |
|
BLAKE2b-256 | 6fd7c9f001687427abb88206e91d81ba60533d8636103bfde7ade3a8e4782000 |