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: MySQLREGEXP- 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)
| File | Size | Uploaded | |
|---|---|---|---|
| sqlrules_mysql-2.0.0.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|