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 hashes)

Uploaded Source

Built Distribution

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