xyberos-crud
Filtering, sorting, and pagination for a collection endpoint — over the database provider contract, as values rather than entities.
A service depends on DatabaseProvider, and a collection route usually needs the same three things: the
caller's filters, the caller's sort order, and one page of rows. xyberos-crud describes all three as
values, applies them to a SQLAlchemy Core select(), and fetches the page — so the query string is parsed
once, in one place, and no field name reaches SQL as text.
It is not an ORM, and that is deliberate
(ADR 0023).
It does not map rows to objects, does not own identity or a session, and does not wrap DatabaseProvider:
a service still opens its own transaction.
Install
pip install xyberos-crud
Use it
from sqlalchemy import MetaData, Table, Column, Integer, String, select
from xyberos.database import DatabaseProvider
from xyberos_crud import CrudSettings, Query, fetch_page
metadata = MetaData()
orders = Table(
"orders",
metadata,
Column("id", Integer, primary_key=True),
Column("status", String(32), nullable=False),
)
# The allowlist. A field name that is not a key here cannot be filtered on, sorted by, or named at all.
FILTERABLE = {"status": orders.c.status, "id": orders.c.id}
SETTINGS = CrudSettings(max_limit=100, default_limit=25)
async def list_orders(provider: DatabaseProvider, parameters: dict[str, str]) -> dict[str, object]:
query = Query.from_parameters(
parameters, filterable=FILTERABLE, settings=SETTINGS
)
statement = select(orders)
page = await fetch_page(
provider, statement, query, filterable=FILTERABLE, settings=SETTINGS
)
return {
"items": [dict(row) for row in page.items],
"limit": page.limit,
"offset": page.offset,
"has_more": page.has_more,
}
from_parameters takes a mapping rather than a Request, so the package needs no HTTP dependency: pass
dict(request.query_params), or build the mapping from anything else you like.
The query string
| Parameter | Meaning |
|---|---|
status=open |
equality |
id__gte=10 |
the operator named after the double underscore |
status__in=open,pending |
a comma-separated list |
name__contains=ada, name__startswith=a |
text matching |
deleted_at__is_null=true |
null, or not null with false |
sort=-created_at,name |
descending, then ascending |
limit=25, offset=50 |
the page; limit is clamped to max_limit |
The operators are eq, ne, lt, lte, gt, gte, in, contains, startswith, and is_null.
Which of them a deployment allows is CrudSettings.allowed_operators.
What it does not do
- No total count.
has_moreis a fact about the page that was fetched. A total is a second query, and a concurrent write can invalidate it before it is rendered. If you need one, run it yourself. - No keyset pagination. This is
LIMIT/OFFSET, which is what an internal tool wants and what drifts under concurrent writes on a large table. A keyset cursor is a different query shape, and it is not here. - No writes. It builds and runs one
SELECT. Insert, update, and delete are your service's, inside your service's transaction. - No ORM, no entity mapping, no identity. It takes a table and returns a statement, so it can answer a query without knowing what a row means.
- No raw SQL. There is no escape hatch, because the moment one exists a field name can reach the database as text.
Metadata
Release files for xyberos-crud 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xyberos_crud-0.1.0.tar.gz | 13.4 kB | With provenance | Details for xyberos_crud-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xyberos_crud-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for xyberos_crud-0.1.0-py3-none-any.whl |
Total release size: 24.3 kB
Release files / xyberos_crud-0.1.0.tar.gz
| Download URL | xyberos_crud-0.1.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4bb9aeec66dcfe067111b4b84dac89498a08ccfd9774d1f958a5f5b04351f4b
|
|
BLAKE2b-256 checksum How to use checksums |
72d107602d9434bc6a78535b9fd30ac258eae6c1988fc4b9f25f53db0901f533
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logRelease files / xyberos_crud-0.1.0-py3-none-any.whl
| Download URL | xyberos_crud-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d456205c89373216f062eb646cef8590270ffb7c73c1d1406bcc089932be892
|
|
BLAKE2b-256 checksum How to use checksums |
ac7bbea817ac894db50461718064d7d52502a9714418f4f02e08dcadedbdfe7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logSecurity for xyberos-crud 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for xyberos_crud-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.
Transparency logA 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.