{"id":14979074,"url":"https://github.com/sqlalchemy-filterset/sqlalchemy-filterset","last_synced_at":"2025-10-10T03:30:38.604Z","repository":{"id":170083793,"uuid":"585464257","full_name":"sqlalchemy-filterset/sqlalchemy-filterset","owner":"sqlalchemy-filterset","description":"SQLAlchemy Filterset.  An easy way to filter, sort, paginate SQLAlchemy queries","archived":false,"fork":false,"pushed_at":"2024-07-27T18:13:31.000Z","size":827,"stargazers_count":55,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-22T05:37:03.310Z","etag":null,"topics":["aiohttp","fastapi","fastapi-filters","fastapi-sqlalchemy","filter","filterset","flask-filter","flask-sqlalchemy","orm","python","python-sql-filter","query-builder","sql","sqlalchemy","sqlalchemy-filter","sqlalchemy-filters-plus","sqlalchemy-filterset","sqlalchemy-query-builder","sqlalchemy-query-filter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqlalchemy-filterset.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-05T08:34:29.000Z","updated_at":"2025-07-01T18:34:01.000Z","dependencies_parsed_at":"2024-07-26T18:48:16.631Z","dependency_job_id":"09bb6111-db99-4977-baee-c16a380c63af","html_url":"https://github.com/sqlalchemy-filterset/sqlalchemy-filterset","commit_stats":{"total_commits":171,"total_committers":10,"mean_commits":17.1,"dds":0.6432748538011697,"last_synced_commit":"576aeabd2405e4ad38e57ba22fc695588e460464"},"previous_names":["sqlalchemy-filterset/sqlalchemy-filterset"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/sqlalchemy-filterset/sqlalchemy-filterset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlalchemy-filterset%2Fsqlalchemy-filterset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlalchemy-filterset%2Fsqlalchemy-filterset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlalchemy-filterset%2Fsqlalchemy-filterset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlalchemy-filterset%2Fsqlalchemy-filterset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlalchemy-filterset","download_url":"https://codeload.github.com/sqlalchemy-filterset/sqlalchemy-filterset/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlalchemy-filterset%2Fsqlalchemy-filterset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002631,"owners_count":26083425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiohttp","fastapi","fastapi-filters","fastapi-sqlalchemy","filter","filterset","flask-filter","flask-sqlalchemy","orm","python","python-sql-filter","query-builder","sql","sqlalchemy","sqlalchemy-filter","sqlalchemy-filters-plus","sqlalchemy-filterset","sqlalchemy-query-builder","sqlalchemy-query-filter"],"created_at":"2024-09-24T13:59:11.307Z","updated_at":"2025-10-10T03:30:38.256Z","avatar_url":"https://github.com/sqlalchemy-filterset.png","language":"Python","readme":"\u003ch1\u003e\n  \u003cspan style=\"font-size: 65px; color: #7e56c2; font-weight: 600\"\u003e\n    \u003cstrong\u003eSQLAlchemy Filterset\u003c/strong\u003e\n  \u003c/span\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"left\"\u003e\n    \u003cem\u003eAn easy way to filter, sort, paginate SQLAlchemy queries\u003c/em\u003e\n\u003c/p\u003e\n\n[![codecov](https://codecov.io/gh/sqlalchemy-filterset/sqlalchemy-filterset/branch/main/graph/badge.svg)](https://codecov.io/gh/sqlalchemy-filterset/sqlalchemy-filterset)\n[![PyPI version](https://badge.fury.io/py/sqlalchemy-filterset.svg)](https://badge.fury.io/py/sqlalchemy-filterset)\n[![Downloads](https://pepy.tech/badge/sqlalchemy-filterset)](https://pepy.tech/project/sqlalchemy-filterset)\n[![CodeQL](https://github.com/sqlalchemy-filterset/sqlalchemy-filterset/actions/workflows/codeql.yml/badge.svg)](https://github.com/sqlalchemy-filterset/sqlalchemy-filterset/actions/workflows/codeql.yml)\n\n\n\u003cimg alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/sqlalchemy-filterset?color=%2334D058\"\u003e\n\u003cimg alt=\"SqlAlchemy - Version\" src=\"https://img.shields.io/badge/sqlalchemy-2.0+-%2334D058\"\u003e\n\n---\n**Documentation**: \u003ca href=\"https://sqlalchemy-filterset.github.io/sqlalchemy-filterset/\" target=\"_blank\"\u003ehttps://sqlalchemy-filterset.github.io/sqlalchemy-filterset\u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/sqlalchemy-filterset/sqlalchemy-filterset\" target=\"_blank\"\u003ehttps://github.com/sqlalchemy-filterset/sqlalchemy-filterset\u003c/a\u003e\n\n---\nThe library provides a convenient and organized way to filter your database records.\nBy creating a `FilterSet` class, you can declaratively define the filters you want to apply to your `SQLAlchemy` queries.\nThis library is particularly useful in web applications, as it allows users to easily search, filter, sort, and paginate data.\n\nThe key features are:\n\n* [X] Declarative definition of filters.\n* [X] Keeping all of your filters in one place, making it easier to maintain and change them as needed.\n* [X] Constructing complex filtering conditions by combining multiple simple filters.\n* [X] Offer of a standard approach to writing database queries.\n* [X] Reduction of code duplication by reusing the same filters in multiple places in your code.\n* [X] Sync and Async support of modern SQLAlchemy.\n\n## Installation\n\n```bash\npip install sqlalchemy-filterset\n```\nRequirements: `Python 3.7+` `SQLAlchemy 2.0+`\n\n\n## Basic FilterSet and Filters Usage\n\nIn this example we specify criteria for filtering the database records\nby simply setting the attributes of the `ProductFilterSet` class.\nThis is more convenient and easier to understand than writing raw SQL queries, which\ncan be more error-prone and difficult to maintain.\n\n### Define a FilterSet\n\n```python\nfrom sqlalchemy_filterset import BaseFilterSet, Filter, RangeFilter, BooleanFilter\n\nfrom myapp.models import Product\n\n\nclass ProductFilterSet(BaseFilterSet):\n    id = Filter(Product.id)\n    price = RangeFilter(Product.price)\n    is_active = BooleanFilter(Product.is_active)\n```\n### Define a FilterSchema\n```python\nimport uuid\nfrom pydantic import BaseModel\n\n\nclass ProductFilterSchema(BaseModel):\n    id: uuid.UUID | None\n    price: tuple[float, float] | None\n    is_active: bool | None\n```\n\n### Usage\n```python\n# Connect to the database\nengine = create_engine(\"postgresql://user:password@host/database\")\nBase.metadata.create_all(bind=engine)\nSessionLocal = sessionmaker(bind=engine)\nsession = SessionLocal()\n\n# Define sqlalchemy query\nquery = select(Product)\n\n# Define parameters for filtering\nfilter_params = ProductFilterSchema(price=(10, 100), is_active=True)\n\n# Create the filterset object\nfilter_set = ProductFilterSet(query)\n\n# Apply the filters to the query\nquery = filter_set.filter_query(filter_params.dict(exclude_unset=True))\n\n# Execute the query\nsession.execute(query).unique().scalars().all()\n```\n\nThis example will generate the following query:\n```sql\nselect product.id, product.title, product.price, product.is_active\nfrom product\nwhere product.price \u003e= 10\n  and product.price \u003c= 100\n  and product.is_active = true;\n```\n\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n\n## Supported by\n\u003ca href=\"https://idaproject.com/\" target=\"_blank\" title=\"idaproject\"\u003e\u003cimg width=150 src=\"https://sqlalchemy-filterset.github.io/sqlalchemy-filterset/img/idaproject.png\"\u003e\u003c/a\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlalchemy-filterset%2Fsqlalchemy-filterset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlalchemy-filterset%2Fsqlalchemy-filterset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlalchemy-filterset%2Fsqlalchemy-filterset/lists"}