attrs-to-sql-0.2.0
توضیحات
Convert attrs class to CREATE TABLE command.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | attrs-to-sql-0.2.0 |
| نام | attrs-to-sql |
| نسخه کتابخانه | 0.2.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | potykion |
| ایمیل نویسنده | potykion@gmail.com |
| آدرس صفحه اصلی | https://github.com/potykion/attrs_to_sql |
| آدرس اینترنتی | https://pypi.org/project/attrs-to-sql/ |
| مجوز | - |
# attrs to sql
Convert [attrs](https://github.com/python-attrs/attrs) class to sql `CREATE TABLE` command.
# Usage
Define class decorated with `attr.s`:
```python
@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:
```python
from attrs_to_sql import attrs_to_table
attrs_to_table(Model)
```
Output:
```sql
CREATE TABLE public.model
(
id int PRIMARY KEY,
name varchar(30) NOT NULL,
floats float[]
);
```
نیازمندی
| مقدار | نام |
|---|---|
| >=18.1.0 | attrs |
| >=2.10 | jinja2 |
نحوه نصب
نصب پکیج whl attrs-to-sql-0.2.0:
pip install attrs-to-sql-0.2.0.whl
نصب پکیج tar.gz attrs-to-sql-0.2.0:
pip install attrs-to-sql-0.2.0.tar.gz