Stack:
Installation
pip install pydantic-sqlalchemy-filter
Usage
Implement UserFilter
from pydantic_sqlalchemy_filter import BaseQueryBuilder, DatabaseModel
class UserFilter(BaseQueryBuilder):
username: str | None = Field(default=None)
order_by: str | None = Field(default='username', alias='orderBy')
def _filter(
self,
model: DatabaseModel,
exclude_deleted: bool = False,
query: sqlalchemy.Select | None = None,
) -> sqlalchemy.Select:
if query is None:
query = self.build_base_query(
model=model,
exclude_deleted=exclude_deleted,
)
if self.username is not None
query = query.filter_by(username=self.username)
return query
In FastAPI router:
@router.get(path='')
async def get_all_filtered_users(
query_builder: Annotated[UserFilter, Depends()],
session: Annotated[AsyncSession, Depends(get_async_session)],
) -> list[Users]:
query = query_builder.build_select_query(model=User)
results = await session.execute(query)
users = results.scalars().all()
return list(users)
Metadata
Release files for pydantic-sqlalchemy-filter 0.1.1
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 |
|---|---|---|---|---|
| pydantic_sqlalchemy_filter-0.1.1.tar.gz | 4.5 kB | Without provenance | Details for pydantic_sqlalchemy_filter-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_sqlalchemy_filter-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pydantic_sqlalchemy_filter-0.1.1-py3-none-any.whl |
Total release size: 10.0 kB
Release files / pydantic_sqlalchemy_filter-0.1.1.tar.gz
| Download URL | pydantic_sqlalchemy_filter-0.1.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94fca02c20b2ed9a1f9b08cc93f468dcfb8fcdb62aafbcd2bffd79b02d214ab4
|
|
BLAKE2b-256 checksum How to use checksums |
a6578d9538d8c1bd1e7e2f63885e8ee15d344b60273183c0b84962fb144a38a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.11.11 Linux/6.8.0-1017-azure
|
Release files / pydantic_sqlalchemy_filter-0.1.1-py3-none-any.whl
| Download URL | pydantic_sqlalchemy_filter-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64e9cc21ef4e40c5972660c8a19bfcd5b26fda77905c0928a5071181ca3acd63
|
|
BLAKE2b-256 checksum How to use checksums |
83fd871baa18b6646c656ed9c53163568f0f5f40c5ed2f29f8b81523d152bde4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.11.11 Linux/6.8.0-1017-azure
|
Security for pydantic-sqlalchemy-filter 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.