Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

rhosocial-activerecord-mariadb ($\rho_{\mathbf{AR}\text{-mariadb}}$)

PyPI version Python Tests Coverage Status Apache 2.0 License Powered by vistart

rhosocial ActiveRecord Logo

MariaDB Backend for rhosocial-activerecord

MariaDB-Compatible Features · System Versioning · Sync & Async

Note: This is a backend implementation for rhosocial-activerecord. It cannot be used standalone.

Why This Backend?

1. MariaDB-Specific Optimizations

Feature This Backend Generic Solutions
Full-Text Search Native MATCH ... AGAINST LIKE-based workarounds
JSON Operations JSON_EXTRACT, ->>, -> Serialize/deserialize overhead
Upsert INSERT ... ON DUPLICATE KEY UPDATE Manual check-then-insert
System Versioning WITH SYSTEM VERSIONING Application-level audit logs

2. True Sync-Async Parity

Same API surface for both sync and async operations:

# Sync
users = User.query().where(User.c.age >= 18).all()

# Async - just add await
users = await User.query().where(User.c.age >= 18).all()

3. Built for Production

  • Connection pooling with configurable pool sizes
  • Transaction support with proper isolation levels
  • Error mapping from MariaDB error codes to Python exceptions
  • Type adapters for MariaDB-specific data types

Quick Start

Installation

pip install rhosocial-activerecord-mariadb

Basic Usage

from rhosocial.activerecord.model import ActiveRecord
from rhosocial.activerecord.backend.impl.mariadb import MariaDBBackend
from rhosocial.activerecord.backend.impl.mariadb.config import MariaDBConnectionConfig
from typing import Optional

class User(ActiveRecord):
    __table_name__ = "users"
    id: Optional[int] = None
    name: str
    email: str

# Configure
config = MariaDBConnectionConfig(
    host="localhost",
    port=3306,
    database="myapp",
    username="user",
    password="password"
)
User.configure(config, MariaDBBackend)

# Use
user = User(name="Alice", email="alice@example.com")
user.save()

# Query with MariaDB full-text search
results = User.query().where(
    "MATCH(name, email) AGAINST(? IN BOOLEAN MODE)",
    ("+Alice",)
).all()

💡 AI Prompt: "Show me how to use JSON operations in MariaDB with this backend"

MariaDB-Specific Features

Full-Text Search

Native MariaDB full-text search support:

# Boolean mode full-text search
Article.query().where(
    "MATCH(title, content) AGAINST(? IN BOOLEAN MODE)",
    ("+python -java",)
).all()

# Natural language mode
Article.query().where(
    "MATCH(title, content) AGAINST(?)",
    ("database optimization",)
).all()

JSON Operations

Query JSON columns using MariaDB's native JSON functions:

# Extract JSON value
User.query().where("settings->>'$.theme' = ?", ("dark",)).all()

# JSON contains
Product.query().where("JSON_CONTAINS(tags, ?)", ('"featured"',)).all()

System-Versioned Tables

MariaDB's temporal tables store full row history:

# Query historical rows
User.query().where(
    "user_id = ? FOR SYSTEM_TIME BETWEEN ? AND ?",
    (1, "2026-01-01", "2026-06-30"),
).all()

Upsert (ON DUPLICATE KEY UPDATE)

Efficient insert-or-update operations:

# Will update on duplicate key
User.insert_or_update(
    name="Alice",
    email="alice@example.com",
    update_fields=["name"]  # Only update name on conflict
)

Requirements

  • Python: 3.9+ (including 3.13t/3.14t free-threaded builds)
  • Core: rhosocial-activerecord>=1.0.0
  • Driver: mariadb>=2.0.0

MariaDB Version Compatibility

Feature Min Version Notes
Basic operations 10.2+ Core functionality
JSON 10.2+ JSON alias for LONGTEXT, JSON functions
Window functions 10.2+ ROW_NUMBER, RANK, etc.
CTEs 10.2+ WITH clauses
Full-text search 10.2+ MATCH ... AGAINST
Generated columns 10.2+ Virtual/Stored columns
CHECK constraints 10.2+ Enforced
DEFAULT expressions 10.2+ Expression defaults
System versioning 10.3+ Temporal tables
Sequences 10.3+ CREATE SEQUENCE
GROUPING SETS 10.3+ Advanced grouping
INET6 type 10.5+ Native IPv6
SKIP LOCKED 10.6+ Row-level locking control

Recommended: MariaDB 10.6+ for optimal feature support.

Get Started with AI Code Agents

This project supports AI-assisted development. Clone and open in your preferred tool:

git clone https://github.com/rhosocial/python-activerecord-mariadb.git
cd python-activerecord-mariadb

Example AI Prompts

  • "How do I configure connection pooling for MariaDB?"
  • "Show me how to use system-versioned tables"
  • "How do I use MariaDB-specific JSON operators?"
  • "Create a model with a FULLTEXT index"

For Any LLM

Feed the documentation files in docs/ to your preferred LLM for context-aware assistance.

Testing

⚠️ CRITICAL: Tests MUST run serially. Do NOT use pytest -n auto or parallel execution.

# Run all tests
PYTHONPATH=src pytest tests/

# Run specific feature tests
PYTHONPATH=src pytest tests/rhosocial/activerecord_mariadb_test/feature/basic/
PYTHONPATH=src pytest tests/rhosocial/activerecord_mariadb_test/feature/query/

See the Testing Documentation for details.

Documentation

Comparison with Other Backends

Feature MariaDB MySQL SQLite
Full-Text Search ✅ Native ✅ Native ⚠️ FTS5 extension
JSON Type ✅ JSON ✅ JSON ⚠️ JSON1 extension
System Versioning ✅ ❌ ❌
Upsert ✅ ON DUPLICATE KEY ✅ ON DUPLICATE KEY ✅ ON CONFLICT
Returning ✅ 10.5+ ❌ ✅ RETURNING

💡 AI Prompt: "When should I choose MariaDB over MySQL for my project?"

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

License

Apache License 2.0 — Copyright © 2026 vistart


Built with ❤️ by the rhosocial team

GitHub · Documentation · PyPI

Metadata

Release files for rhosocial-activerecord-mariadb 1.0.0.dev2

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

Source distribution (sdist)

Source distribution for rhosocial-activerecord-mariadb 1.0.0.dev2
File Size Uploaded
rhosocial_activerecord_mariadb-1.0.0.dev2.tar.gz 176.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rhosocial-activerecord-mariadb 1.0.0.dev2
File Interpreter ABI Platform
rhosocial_activerecord_mariadb-1.0.0.dev2-py3-none-any.whl Python 3 none any Details

Total release size: 457.0 kB

Release files / rhosocial_activerecord_mariadb-1.0.0.dev2.tar.gz

Download URL rhosocial_activerecord_mariadb-1.0.0.dev2.tar.gz
Size 176.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3cddaf34788fbcca974c76085949ccfb92639cf94aa456f74b551e16afdc224c
BLAKE2b-256 checksum
How to use checksums
89edc86ef32b5346e4244333b2460afbdfed67bfa2d8eadd0aaeb9a883808209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / rhosocial_activerecord_mariadb-1.0.0.dev2-py3-none-any.whl

Download URL rhosocial_activerecord_mariadb-1.0.0.dev2-py3-none-any.whl
Size 281.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cae4903922d88a222b60028cc7e33ce1dd2c56becdb3f91703c9c4c75221248d
BLAKE2b-256 checksum
How to use checksums
e1bb4c9a288e2303b6f5641ef1574966c2bab6a7e2bc210b701ada93db4047d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0.dev2 This release

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