Skip to main content

sqlrules-mysql

MySQL backend provider for SQLRules. The package version follows the core 2.x line.

This provider targets MySQL 8.0+. MariaDB is outside the supported server matrix because its regular-expression function API differs from MySQL's.

Install

pip install "sqlrules>=2,<3" "sqlrules-mysql>=2,<3"

Use

from typing import Annotated, Any

from pydantic import Field
from sqlalchemy import Column, JSON, MetaData, String, Table

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

rows = Table(
    "rows",
    MetaData(),
    Column("name", String),
    Column("meta", JSON),
    Column("body", String),
)


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


provider = MysqlPlugin(server_version=(8, 0, 36))
compiled = Compiler(plugins=[provider]).compile(RowRules, rows)
statement = rows.select().where(*where(compiled))

Capabilities

  • pattern: MySQL REGEXP
  • JSON containment and key lookup
  • Full-text matching (requires a matching FULLTEXT index)
  • Safe lax text-to-int conversion on MySQL 8.0+

Text-to-float and text-to-Decimal are compile-time capability errors. String Literal and Enum fields need an explicit binary or case-sensitive collation. See the type support matrix.

Pattern cost

Untrusted regular expressions and full-text queries can be expensive. Prefer static or allowlisted values. See the SQLRules security notes.

Metadata

Release files for sqlrules-mysql 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlrules-mysql 2.0.0
File Size Uploaded
sqlrules_mysql-2.0.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlrules-mysql 2.0.0
File Interpreter ABI Platform
sqlrules_mysql-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / sqlrules_mysql-2.0.0.tar.gz

Download URL sqlrules_mysql-2.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
61f64b5c0209d38f53fad9b082efb4240efae0ffa3fbcd6cb716b7e37326ec4b
BLAKE2b-256 checksum
How to use checksums
2ed1c1cdafc2640bf1e15f0d249b0039824ff11a940549c8907f3786adb2764e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sqlrules_mysql-2.0.0-py3-none-any.whl

Download URL sqlrules_mysql-2.0.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
059bc029ac9927aa48d0b29b06fc993e11da0d0966327a51be1d49072e9712c0
BLAKE2b-256 checksum
How to use checksums
1b88695587eb802d9d3ff8086d6a7b317f245f791b33e3523fd5b19ec0df2e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page