Skip to main content

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[]
);

Release files for attrs-to-sql 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for attrs-to-sql 0.2.0
File Size Uploaded
attrs_to_sql-0.2.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for attrs-to-sql 0.2.0
File Interpreter ABI Platform
attrs_to_sql-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / attrs_to_sql-0.2.0.tar.gz

Download URL attrs_to_sql-0.2.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ff1380b4996deb1800f44d40601f6056b217203ab1ae7c1233d279982751585d
BLAKE2b-256 checksum
How to use checksums
0a7376e27191bd81c84defdf685b8d0d3419216a8cbf08c84cc62fd3f08a5e9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release files / attrs_to_sql-0.2.0-py3-none-any.whl

Download URL attrs_to_sql-0.2.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb1cedc552e639818ad2360a677c6a904c4a598778261f9c8ac4c50b78b90b7c
BLAKE2b-256 checksum
How to use checksums
6fd7c9f001687427abb88206e91d81ba60533d8636103bfde7ade3a8e4782000
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page