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.6.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for attrs_to_sql-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c293351a13eb18892f36e422d6f97dc3f04ab62969f8c171f9cfb4910a10d81 |
|
MD5 | 5c4db659845bf3966d450d3617fa2658 |
|
BLAKE2b-256 | cbdc6bf319131352546c021cdf1c4ce40dfdce87ea2b92bc9fcb23ffb6ca608d |