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.1.0.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for attrs_to_sql-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4463f872c8818ebd55eabd71b410aa04bc871a51bacf9bc04fa1217c88c472c3 |
|
MD5 | 53ebb6a5b468402e90e81cadf96e923f |
|
BLAKE2b-256 | 7e44b0fc868075a2986856042a08e0480c89b8acd533339efe8a40087e54cbf9 |