Skip to main content

sqlrules-mssql

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

Install

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

Use

from typing import Annotated, Any

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

from sqlrules import Compiler, JsonContains, JsonHasKey, RuleSchema, where
from sqlrules_mssql import MssqlPlugin

rows = Table(
    "rows",
    MetaData(),
    Column("name", String),
    Column("meta", String),  # SQL Server stores JSON documents in text columns.
)


class RowRules(RuleSchema):
    name: Annotated[str, Field(min_length=2, max_length=40)]
    meta: Annotated[dict[str, Any], JsonContains({"active": True}), JsonHasKey("active")]


provider = MssqlPlugin(server_version=(16, 0), compatibility_level=160)
compiled = Compiler(plugins=[provider]).compile(RowRules, rows)
statement = rows.select().where(*where(compiled))

Capabilities

  • SQL Server LEN length constraints
  • Guarded JSON helpers for text columns validated with ISJSON (server_version >= 13 and explicit compatibility_level >= 130)
  • JsonContains supports null, boolean, and string values; nested objects and arrays compare structurally, while numeric JSON values raise CapabilityError because exact numeric equality cannot be guaranteed from OPENJSON text values
  • Safe lax text-to-int/float conversions on SQL Server 2012+
  • No built-in regex translator
  • Text-to-Decimal is a compile-time capability error

String Literal and Enum fields require an explicit binary or case-sensitive collation. See the type support matrix.

Metadata

Release files for sqlrules-mssql 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-mssql 2.0.0
File Size Uploaded
sqlrules_mssql-2.0.0.tar.gz 7.2 kB Details

Built distribution (wheel)

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

Total release size: 15.2 kB

Release files / sqlrules_mssql-2.0.0.tar.gz

Download URL sqlrules_mssql-2.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a60806c5990f4bdc4423dc58ababc1d9ab5bd2c3ac02b46a467e8eb7b24280bd
BLAKE2b-256 checksum
How to use checksums
9fc8c4c9e5e0a0566eef9be10a10d05d78e0f9f92a25626bd097d367195ae25f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL sqlrules_mssql-2.0.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
332635c660b9a45f4ab7bb1883c700d5da0c036687a5d65f0cf2294ab03d43b0
BLAKE2b-256 checksum
How to use checksums
2187268f555e7d62f982717db97c8240f40ae35e81a27ae3080323f01eb633db
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