Skip to main content

MySQL/MariaDB dialect plugin for SQLRules (REGEXP, JSON, full-text).

Project description

sqlrules-mysql

MySQL / MariaDB dialect plugin for SQLRules.

Install

pip install sqlrules-mysql

Usage

from typing import Annotated, Any

from pydantic import BaseModel, Field

from sqlrules import Compiler, FullTextMatch, JsonContains
from sqlrules_mysql import MysqlPlugin

class RowFilter(BaseModel):
    name: Annotated[str, Field(pattern=r"^A")]
    meta: Annotated[dict[str, Any], JsonContains({"active": True})]
    body: Annotated[str, FullTextMatch("sqlrules")]

compiler = Compiler(plugins=[MysqlPlugin()], dialect="mysql")

Operators

IR operator Notes
pattern REGEXP (case-insensitive under typical collations)
type_check Shape/type predicates from TypeSpec (partial matrix)
json_contains JSON_CONTAINS(column, payload) = 1
json_has_key JSON_CONTAINS_PATH(column, 'one', '$.key') = 1
fulltext_match MATCH(column) AGAINST (value) — requires a FULLTEXT index

Security note

pattern / fulltext_match values are bound parameters, but evaluation cost is engine-dependent. Prefer static/allowlisted patterns and queries from untrusted input. See SECURITY.

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

sqlrules_mysql-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

sqlrules_mysql-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file sqlrules_mysql-1.0.0.tar.gz.

File metadata

  • Download URL: sqlrules_mysql-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for sqlrules_mysql-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5731ce4a262ee911771281952e579e1ca3221f7caad3e4576c074167b9904d76
MD5 cb0de1abc7df612ac20b829229e6c81f
BLAKE2b-256 60c86fe03f7d3366b44a0e7d5967dece980f2a232573e943e571f4350e1c1655

See more details on using hashes here.

File details

Details for the file sqlrules_mysql-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sqlrules_mysql-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sqlrules_mysql-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4cbc9bb051b543d842b780f2bd474aceb5a2ec958cc75eb430a30ccc17daeb6
MD5 876dd87359cb6ce1127551138440c88e
BLAKE2b-256 6a0ac7ef80ff38b7d9a09109ad1c94252ed6167170479fa410a5c999b31b2c83

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