A lite version of fastapi-filter for SQLAlchemy only
Project description
FastAPI filter
Compatibility
Required:
- Python: >=3.8, <3.12
- Fastapi: >=0.78, <0.93
- Pydantic: >=1.10.0, <2.0.0
- SQLAlchemy: >=1.4.36, <2.1.0
Installation
# Lite version
pip install fastapi-sqlalchemy-filter
Documentation
This package was inspired by arthurio
The package is a lite version for SQLAlchemy only with a few modifications to it.
Please visit this site to view the full documentation: https://fastapi-filter.netlify.app/
Modifications / Additions
You can import the Filter
class and create a filter on the fly:
from fastapi_sqlalchemy_filter import Filter
user_dict = {'name': 'Jon Snow', 'clan': 'Targaryen'}
user_filter = Filter(**user_dict)
Package returns None
if an ordering field is not present on the class definition.
Note: No user action is needed on this part
This function was modified from:
...
@property
def ordering_values(self):
"""Check that the ordering field is present on the class definition."""
try:
return getattr(self, self.Constants.ordering_field_name)
except AttributeError:
raise AttributeError(
f"Ordering field {self.Constants.ordering_field_name} is not defined. "
"Make sure to add it to your filter class."
)
...
To
...
@property
def ordering_values(self):
"""Check that the ordering field is present on the class definition."""
if hasattr(self, self.Constants.ordering_field_name):
return getattr(self, self.Constants.ordering_field_name)
return None
...
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for fastapi_sqlalchemy_filter-0.2.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49250b9a317d0b9741a48c710e3288920c5669068a84dbfb0800d7fe95350679 |
|
MD5 | fe5129fb5d728b1469b6816d152d24e1 |
|
BLAKE2b-256 | fc75fdc90f6bbae075d9b86af13f9594ec7e5473a6fdd3f8244096bb7c139937 |
Close
Hashes for fastapi_sqlalchemy_filter-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | deff1903d79f5493fbde569568181412b04f1a997befa20b4d2940b44f72f4de |
|
MD5 | 6b84a2e06af9eeed7dea8c8deade7de1 |
|
BLAKE2b-256 | f7ff830c8c4860c05c0df7f45b63ee55f335d79467b866ae2370f697a6d6bbd9 |