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.7.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for attrs_to_sql-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b8d84e90b6033e91329265d2b2ddddb6799e7af59804b1e597e97d1150f2e9d |
|
MD5 | 1228fb4ab07696dedeb4a5c11f2a0dfc |
|
BLAKE2b-256 | d01bed200418865def82a3c8cdc44280a06a90b90c975bd83e9045cdd6223aae |