Skip to main content

A library providing reusable utilities for SQLAlchemy.

Project description

unboil-sqlalchemy-utils

Async pagination for SQLAlchemy (async) queries.

Example

from sqlalchemy import select
from unboil_sqlalchemy_utils import paginate, count, fetch_all, fetch_one

# Paginate results for a model
result = await paginate(
    session=my_async_session,
    statement=select(MyModel),
    offset=0,   # start index
    limit=10    # page size
)
print(result.items)         # List of items for this page
print(result.total)         # Total number of items
print(result.total_pages)   # Total number of pages
print(result.current_page)  # Current page (1-based)
print(result.has_more)      # True if more results exist

# Fetch all results (no pagination)
all_items = await fetch_all(my_async_session, select(MyModel))

# Fetch a single result
one_item = await fetch_one(my_async_session, select(MyModel).where(MyModel.id == 1))

# Count total rows for a query
total = await count(my_async_session, select(MyModel))

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unboil_sqlalchemy_utils-0.1.3.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unboil_sqlalchemy_utils-0.1.3-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file unboil_sqlalchemy_utils-0.1.3.tar.gz.

File metadata

  • Download URL: unboil_sqlalchemy_utils-0.1.3.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unboil_sqlalchemy_utils-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d3d83f985b058414c0f56db2fa6409eb47e1b9bdab7f35322d75ab98c0700f25
MD5 22319df16b42143370c34d687efb2d65
BLAKE2b-256 0d5400bb9eb3609aa5b4ad4908da1e6090ac10765b6df4f398c7441c714fcf38

See more details on using hashes here.

File details

Details for the file unboil_sqlalchemy_utils-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for unboil_sqlalchemy_utils-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e3c1fa366de53c99d09b7b0e2f9d699a6eecab27f11c331f4ca9506624ef8524
MD5 3eb496967a54315e514d0177f9005b6e
BLAKE2b-256 3e1d2f2a73be5f5691d0420e07d13f2cb8c94ab04b957b684eb08b602d95d7f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page