Skip to main content

pydal2sql-core

PyPI - Version PyPI - Python Version
Code style: black License: MIT
su6 checks coverage.svg


Companion library for pydal2sql containing the actual logic. The other library only serves as a Typer-based CLI front-end.

More Documentation coming soon!

Table of Contents

Installation

pip install pydal2sql-core

As a Python Library

pydal2sql-core also exposes a generate_sql method that can perform the same actions on one (for CREATE) or two (for ALTER) pydal.Table objects when used within Python.

from pydal import DAL, Field
from pydal2sql_core import generate_sql

db = DAL(None, migrate=False)  # <- without running database or with a different type of database

person_initial = db.define_table(
    "person",
    Field(
        "name",
        "string",
        notnull=True,
    ),
    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
);
person_new = db.define_table(
    "person",
    Field(
        "name",
        "text",
    ),
    Field("birthday", "datetime"),
    redefine=True
)

generate_sql(
    person_initial,
    person_new,
    db_type="psql"
)
ALTER TABLE person
    ADD "name__tmp" TEXT;
UPDATE person
SET "name__tmp"=name;
ALTER TABLE person DROP COLUMN name;
ALTER TABLE person
    ADD name TEXT;
UPDATE person
SET name="name__tmp";
ALTER TABLE person DROP COLUMN "name__tmp";
ALTER TABLE person
    ADD birthday TIMESTAMP;
ALTER TABLE person DROP COLUMN age;
ALTER TABLE person DROP COLUMN float;
ALTER TABLE person DROP COLUMN nicknames;
ALTER TABLE person DROP COLUMN obj;

License

pydal2sql-core is distributed under the terms of the MIT license.

Metadata

Release files for pydal2sql-core 0.7.4

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

Source distribution (sdist)

Source distribution for pydal2sql-core 0.7.4
File Size Uploaded Provenance Actions
pydal2sql_core-0.7.4.tar.gz 24.6 kB Without provenance Details for pydal2sql_core-0.7.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydal2sql-core 0.7.4
File Interpreter ABI Platform Actions
pydal2sql_core-0.7.4-py3-none-any.whl Python 3 none any Details for pydal2sql_core-0.7.4-py3-none-any.whl

Total release size: 50.3 kB

Release files / pydal2sql_core-0.7.4.tar.gz

Download URL pydal2sql_core-0.7.4.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ee22e2f66168701cde44a8d0d96e5615a172ace0e632e16fa5e3c6be020b29a
BLAKE2b-256 checksum
How to use checksums
b3f95d802e1ff51cf7e56b40bea4746bba9c5f5eb78eedf043fe04c05ba75cff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pydal2sql_core-0.7.4-py3-none-any.whl

Download URL pydal2sql_core-0.7.4-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
086a0a81d416e8a75d1aad499629932af7d883da0667ace6b59ebe5926d0b130
BLAKE2b-256 checksum
How to use checksums
6b663ec65f5ddc90203d6af54a6c5a8e4197a101262c83de5e5d329fa5921b57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pydal2sql-core 0.7.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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