Convert pydal define_tables to SQL using pydal's CREATE TABLE logic
Project description
pydal2sql
Convert pydal define_tables to SQL using pydal's CREATE TABLE logic
Table of Contents
Example
from pydal import DAL, Field
from pydal2sql import generate_sql
db = DAL(None, migrate=False) # <- without running database or with a different type of database
db.define_table(
"person",
Field(
"name",
"string",
nullable=False,
),
Field("age", "integer", default=18),
Field("float", "decimal(2,3)"),
Field("nicknames", "list:string"),
Field("obj", "json"),
),
print(
generate_sql(
db.person, db_type="psql" # or sqlite, or mysql; Optional with fallback to currently using database type.
)
)
CREATE TABLE person
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(512),
age INTEGER,
float NUMERIC(2, 3),
nicknames TEXT,
obj TEXT
);
Installation
pip install pydal2sql
License
pydal2sql
is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydal2sql-0.1.0.tar.gz
(37.2 kB
view hashes)
Built Distribution
Close
Hashes for pydal2sql-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 010a0502efed8b6467c9f716c1721eae30f7d98c24d9da66c3cf8da31dc1043c |
|
MD5 | 14ea9dc496fa342368895054814f63de |
|
BLAKE2b-256 | 3cf1d14d11971081425bb66c340bee7e1b1bdee192e076d3a15f7d431efbcd6c |