Note: This is a backend implementation for rhosocial-activerecord. It cannot be used standalone.
| 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 |
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()- 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
pip install rhosocial-activerecord-mariadbfrom 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"
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()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()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()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
)- Python: 3.9+ (including 3.13t/3.14t free-threaded builds)
- Core:
rhosocial-activerecord>=1.0.0 - Driver:
mariadb>=2.0.0
| 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.
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- "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"
Feed the documentation files in docs/ to your preferred LLM for context-aware assistance.
β οΈ CRITICAL: Tests MUST run serially. Do NOT usepytest -n autoor 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.
- Getting Started β Installation and configuration
- MariaDB Features β MariaDB-specific capabilities
- Type Adapters β Data type handling
- Transaction Support β Transaction management
| Feature | MariaDB | MySQL | SQLite |
|---|---|---|---|
| Full-Text Search | β Native | β Native | |
| JSON Type | β JSON | β JSON | |
| 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?"
We welcome contributions! See CONTRIBUTING.md for guidelines.
Apache License 2.0 β Copyright Β© 2026 vistart
Built with β€οΈ by the rhosocial team
GitHub Β· Documentation Β· PyPI