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

Uploaded Python 3

File details

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

File metadata

  • Download URL: unboil_sqlalchemy_utils-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 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.1.tar.gz
Algorithm Hash digest
SHA256 0ebcc75c222751a7bfc95e48c618f09fda8858cc364661ded4343a4bbfdb6249
MD5 c759b5c6506eb96620b09f5051c6f498
BLAKE2b-256 390fefc6ec6fb6f443f2d6d4bdae09d5e7b27f97289add81bc1a0f4f3298e362

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unboil_sqlalchemy_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c74cbfbf2ec6e78d2e38dc093d4370fe6de5fb9c76eebe7fa08356a4f71f4b3c
MD5 ae45276784af604cd18ded3b31352a35
BLAKE2b-256 c27e228bbaba40ea9d23fb1dd58660c2a77e32807a30330241fe4103b12fab71

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