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
  • 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


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.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fastapi_sqlalchemy_filter-0.2.4.tar.gz.

File metadata

File hashes

Hashes for fastapi_sqlalchemy_filter-0.2.4.tar.gz
Algorithm Hash digest
SHA256 c38524daef7299be93ca5c85137662594a2a8158b81faa583c2ecf171f871b1e
MD5 b87a3fbc042710a7865eb5fbb10ff94b
BLAKE2b-256 6371d4925fb70d3971f1d2bdd321a3c34ddd06a5e4798a738b89dcbdcbcb66ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_sqlalchemy_filter-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d0003d7287c6d9a04e50d9b686236a3de5a2a529a9919bb16263054ab45ef1f9
MD5 f824f6a89f65b79ee0bcf8ada26510bf
BLAKE2b-256 f8b51071f7c92267e6724dba48b5d5a4d8c678c9a18560e41570c0ba297f5676

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