Skip to main content

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

Optional

  • SQLAlchemy: >=1.4.36, <2.1.0

Installation


# Lite version
pip install fastapi-sqlalchemy-filter-lite

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-sqlalchemy-filter-0.2.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fastapi-sqlalchemy-filter-0.2.1.tar.gz.

File metadata

File hashes

Hashes for fastapi-sqlalchemy-filter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3fdc8a36697b8524dc36ff87767cbf98bfc3d2d5f8d5a350c4daaf87f044aef0
MD5 5e88dbb0d333e7d193bd42b86d34326a
BLAKE2b-256 cf7d82bc93c3f35db5961fa4486ae0e08bcbddafcfed9d3e332c613f8fa9d0b8

See more details on using hashes here.

File details

Details for the file fastapi_sqlalchemy_filter-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_sqlalchemy_filter-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7781b85613e0bc80edaa3d5f9775d0c27602f17c8b280667ed360f0357598934
MD5 71bcaffa5c173b75dce204b7f4206557
BLAKE2b-256 7d6e4f2c37c19bcf5e1fbe08f78f7bc4d611a5b900c8e219efdc981f746c781c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page