https://github.com/rhosocial/python-activerecord-mariadb
A MariaDB backend implementation that brings MariaDB's robust features and performance optimizations to the ActiveRecord pattern while maintaining its elegant Pythonic interface.
https://github.com/rhosocial/python-activerecord-mariadb
activerecord database mariadb orm python
Last synced: about 1 month ago
JSON representation
A MariaDB backend implementation that brings MariaDB's robust features and performance optimizations to the ActiveRecord pattern while maintaining its elegant Pythonic interface.
- Host: GitHub
- URL: https://github.com/rhosocial/python-activerecord-mariadb
- Owner: rhosocial
- License: apache-2.0
- Created: 2025-02-27T08:40:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-05-16T18:03:53.000Z (about 2 months ago)
- Last Synced: 2026-05-16T20:19:56.494Z (about 2 months ago)
- Topics: activerecord, database, mariadb, orm, python
- Language: Python
- Homepage:
- Size: 519 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.d/.gitkeep
- License: LICENSE
Awesome Lists containing this project
README
# rhosocial ActiveRecord MariaDB Backend
[](https://badge.fury.io/py/rhosocial-activerecord-mariadb)
[](https://pypi.org/project/rhosocial-activerecord-mariadb/)
[](https://github.com/rhosocial/python-activerecord-mariadb/actions)
[](https://app.codecov.io/gh/rhosocial/python-activerecord-mariadb/tree/main)
[](https://github.com/rhosocial/python-activerecord-mariadb/blob/main/LICENSE)
[](https://github.com/vistart)
MariaDB backend implementation for rhosocial-activerecord, providing a robust and optimized MariaDB database support.
## Overview
This package provides MariaDB backend support for the [rhosocial-activerecord](https://github.com/rhosocial/python-activerecord) ORM framework. It enables seamless integration with MariaDB databases while leveraging all the features of the ActiveRecord pattern implementation.
## Features
> This project is still under development and features are subject to change. Please stay tuned for the latest changes.
- 🚀 Optimized MariaDB-specific query generation
- 🔒 Full support for MariaDB's unique features
- 📦 Connection pooling support (optional)
- 🔄 Comprehensive transaction management
- 🔍 Advanced query capabilities specific to MariaDB
- 🔌 Simple configuration and setup
## Requirements
- Python 3.8+
- rhosocial-activerecord 1.0.0+
- mariadb 1.1.0+
## Installation
```bash
# Basic installation
pip install rhosocial-activerecord-mariadb
# With connection pooling support
pip install rhosocial-activerecord-mariadb[pooling]
# With development tools
pip install rhosocial-activerecord-mariadb[dev]
```
## Usage
```python
from rhosocial.activerecord import ActiveRecord
from rhosocial.activerecord.backend.impl.mariadb.backend import MariaDBBackend
from rhosocial.activerecord.backend.typing import ConnectionConfig
from datetime import datetime
from typing import Optional
class User(ActiveRecord):
__table_name__ = 'users'
id: int
name: str
email: str
created_at: datetime
deleted_at: Optional[datetime] = None
# Configure with MariaDB backend
User.configure(
ConnectionConfig(
host='localhost',
port=3306,
database='myapp',
user='dbuser',
password='dbpassword'
),
backend_class=MariaDBBackend
)
# Create a table (if not exists)
User.create_table_if_not_exists()
# Create a new user
user = User(name='John Doe', email='john@example.com', created_at=datetime.now())
user.save()
# Query users
active_users = User.query() \
.where('deleted_at IS NULL') \
.order_by('created_at DESC') \
.all()
# Update user
user.name = 'Jane Doe'
user.save()
# Delete user (soft delete if implemented)
user.delete()
```
## Advanced MariaDB Features
This backend supports MariaDB-specific features and optimizations:
```python
# Using MariaDB fulltext search
results = User.query() \
.where('MATCH(name, email) AGAINST(? IN BOOLEAN MODE)', ('+John -Doe', )) \
.all()
# Using MariaDB JSON operations
results = User.query() \
.where('JSON_EXTRACT(settings, "$.notifications") = ?', ('enabled', )) \
.all()
# Batch insert with ON DUPLICATE KEY UPDATE
User.batch_insert_or_update([user1, user2, user3])
```
## Documentation
Complete documentation is available at [python-activerecord MariaDB Backend](https://docs.python-activerecord.dev.rho.social/backends/mariadb.html)
## Contributing
We welcome and value all forms of contributions! For details on how to contribute, please see our [Contributing Guide](https://github.com/rhosocial/python-activerecord-mariadb/blob/main/CONTRIBUTING.md).
## License
[](https://github.com/rhosocial/python-activerecord-mariadb/blob/main/LICENSE)
Copyright © 2025 [vistart](https://github.com/vistart)