Skip to main content

sqla-utils

Opinionated utilities for working with SQLAlchemy

MIT License PyPI - Python Version GitHub pypi GitHub Workflow Status

Contents

Transaction Wrapper

FIXME

DBObjectBase

DBObjectBase is a base class for mapped classes.

Example:

from datetime import datetime
from sqlalchemy import Column, DateTime, Integer, String
from sqla_utils import DBObjectBase, Transaction

class DBAppointment(DBObjectBase):
    __tablename__ = "appointments"

    id = Column(Integer, primary_key=True)
    date = Column(DateTime, nullable=False)
    description = Column(String(1000), nullable=False, default="")

Appointment items can then be queried like this:

from sqla_utils import begin_transaction

with begin_transaction() as t:
    app123 = DBAppointment.fetch_by_id(t, 123)
    great_apps = DBAppointment.fetch_all(t, DBAppointment.description.like("%great%"))

It is recommended to add custom query, creation, and update methods:

class DBAppointment(DBObjectBase):
    ...

    @classmethod
    def create(cls, t: Transaction, date: datetime, description: str) -> DBAppointment:
        o = cls()
        o.date = date
        o.description = description
        t.add(o)
        return o

    @classmethod
    def fetch_all_after(cls, t: Transaction, date: datetime) -> List[DBAppointment]:
        return cls.fetch_all(t, cls.start >= dates.start)

    def update_description(self, t: Transaction, new_description: str) -> None:
        self.description = new_description
        t.changed(self)

Database Builder

FIXME

pytest Utilities

The sqla_utils.test module contains a few utilities for working with pytest and SQLAlchemy.

FIXME

Metadata

Release files for sqla-utils 0.9.1

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

Source distribution (sdist)

Source distribution for sqla-utils 0.9.1
File Size Uploaded Provenance Actions
sqla_utils-0.9.1.tar.gz 13.7 kB Without provenance Details for sqla_utils-0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqla-utils 0.9.1
File Interpreter ABI Platform Actions
sqla_utils-0.9.1-py3-none-any.whl Python 3 none any Details for sqla_utils-0.9.1-py3-none-any.whl

Total release size: 28.6 kB

Release files / sqla_utils-0.9.1.tar.gz

Download URL sqla_utils-0.9.1.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
73bd5ef3809cc7393217b577e974480f3140b347dae850e550932c7deae76142
BLAKE2b-256 checksum
How to use checksums
f887a960b68c330f7b8bd318d29c0164341bae21e3d69806d080763a722ea18b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sqla_utils-0.9.1-py3-none-any.whl

Download URL sqla_utils-0.9.1-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9560d637b096d5030dbad31f63687b17eb54d05bd2cf38c528e7d833bcb1f69
BLAKE2b-256 checksum
How to use checksums
7d1711b69f4bb0175d79255bd6f2898b7a6a5d76505d543f340802e20c0de081
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sqla-utils 0.9.1

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