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.2.tar.gz (14.9 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.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unboil_sqlalchemy_utils-0.1.2.tar.gz
  • Upload date:
  • Size: 14.9 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.2.tar.gz
Algorithm Hash digest
SHA256 baffd68d6ee7f09dece6f5c550070a6e2fd46ea5c02c79b5514bdab613c0b7de
MD5 48f61f8a893b6c4ce29fbcd5ed67180a
BLAKE2b-256 6e72dce2e023542fdeaf1908504281ce35a675c66ddf14808b8e7badc091e218

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unboil_sqlalchemy_utils-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 06e2370b59c841971b7f3fd82477ab8688b3220b7c42dde6f50c681ea2cb3284
MD5 6984f937e6e488ba36f7d1a6867e0341
BLAKE2b-256 f71fc9d3958b5b2868f9a4f713ed244f5ec0db35f310ba272569387c3a24fc7f

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