Skip to main content

Add your description here

Project description

AIP-160 Filter Helper for SQLAlchemy

Usage

  from sqlalchemy import select
  from utils.aip160_filter import apply_filter

Basic filtering

 query = select(MyModel)
 filtered = apply_filter(query, MyModel, 'status = "active"')

Multiple conditions

  filtered = apply_filter(query, MyModel, 'status = "active" AND priority > 3')

OR conditions

  filtered = apply_filter(query, MyModel, 'status = "active" OR status = "pending"')

NOT operator

  filtered = apply_filter(query, MyModel, 'NOT status = "inactive"')

Wildcard pattern matching

  filtered = apply_filter(query, MyModel, 'name = "Widget*"')

Presence check (field is not null)

  filtered = apply_filter(query, MyModel, 'category:*')

Complex nested expressions

  filtered = apply_filter(
      query, MyModel,
      '(status = "active" OR status = "pending") AND priority >= 3'
  )

Restrict filterable fields for security

  filtered = apply_filter(
      query, MyModel, 'status = "active"',
      allowed_fields={"status", "priority"}  # Only these fields can be filtered
  )

Supported Features

Feature Example Notes
Equality status = "active" String, int, float, bool, UUID
Not equals status != "inactive"
Comparisons priority > 3, score <= 4.5 <, >, <=, >=
AND a = 1 AND b = 2 Explicit
Implicit AND a = 1 b = 2 Adjacent terms
OR a = 1 OR a = 2 Higher precedence than AND per AIP-160
NOT NOT status = "active" Also -status = "active"
Parentheses (a OR b) AND c
Wildcards name = "*.txt" Converted to SQL LIKE
Presence field:* Field is not null
Has value field:value Field equals value

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

sqlalchemy_aip160-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_aip160-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_aip160-0.1.1.tar.gz.

File metadata

  • Download URL: sqlalchemy_aip160-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sqlalchemy_aip160-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b6d34ff6860890189752c7f2f7230ec058ac35faef3980f0673071f891367e28
MD5 301e057a426243e26734f7c1b4b515aa
BLAKE2b-256 aaba0e9430b3ec770fc5400a1f6f9f6bf962c9fde994c32e33168499bf22dac7

See more details on using hashes here.

File details

Details for the file sqlalchemy_aip160-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemy_aip160-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sqlalchemy_aip160-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b08a5449282071315f154ec263d9ab69678aafa9ba0efec029f98346c5256551
MD5 4e8e842e2a5b07aaab65b0043c9b824d
BLAKE2b-256 7ae9bf86979b39948ced5f0698e3d006d9f3174257a4d412c883eeb78da638de

See more details on using hashes here.

Supported by

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