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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3d83f985b058414c0f56db2fa6409eb47e1b9bdab7f35322d75ab98c0700f25
|
|
| MD5 |
22319df16b42143370c34d687efb2d65
|
|
| BLAKE2b-256 |
0d5400bb9eb3609aa5b4ad4908da1e6090ac10765b6df4f398c7441c714fcf38
|
File details
Details for the file unboil_sqlalchemy_utils-0.1.3-py3-none-any.whl.
File metadata
- Download URL: unboil_sqlalchemy_utils-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3c1fa366de53c99d09b7b0e2f9d699a6eecab27f11c331f4ca9506624ef8524
|
|
| MD5 |
3eb496967a54315e514d0177f9005b6e
|
|
| BLAKE2b-256 |
3e1d2f2a73be5f5691d0420e07d13f2cb8c94ab04b957b684eb08b602d95d7f8
|