ODBMS - Object Document/Relational Mapping System
A flexible and modern Python ORM supporting multiple databases (MongoDB, PostgreSQL, MySQL) with both synchronous and asynchronous operations.
Features
- Support for multiple databases:
- SQLite (using sqlite3)
- MongoDB (using Motor)
- PostgreSQL (using aiopg)
- MySQL (using aiomysql)
- Both synchronous and asynchronous operations
- Connection pooling for better performance
- Type-safe field definitions
- Pydantic integration for validation
- Automatic table/collection creation
- Relationship handling
- Computed fields
- Flexible query interface
Installation
pip install -r requirements.txt
Quick Start
from odbms import Model, StringField, IntegerField, EmailField
from odbms.dbms import DBMS
# Initialize database connection
DBMS.initialize(
dbms='postgresql', # or 'mongodb', 'mysql'
host='localhost',
port=5432,
database='mydb',
username='user',
password='pass'
)
# Define your model
class User(Model):
name: str = StringField()
email: str = EmailField()
age: int = IntegerField(min_value=0)
# Create a new user
user = User(name='John Doe', email='john@example.com', age=30)
await user.save_async() # or user.save() for sync operation
# Find users
users = await User.find_async({'age': {'$gte': 25}}) # or User.find() for sync
Field Types
StringField: For text dataIntegerField: For integer valuesFloatField: For floating-point numbersBooleanField: For true/false valuesDateTimeField: For timestampsEmailField: For email addresses with validationIDField: For primary keys/IDsComputedField: For dynamically computed valuesListField: For arrays/listsDictField: For nested documents/objects
Database Operations
Synchronous Operations
# Create
user = User(name='John', email='john@example.com')
user.save()
# Read
user = User.find_one({'email': 'john@example.com'})
users = User.find({'age': {'$gte': 25}})
all_users = User.all()
# Update
User.update({'age': {'$lt': 18}}, {'is_minor': True})
# Delete
User.remove({'status': 'inactive'})
# Aggregation
total_age = User.sum('age', {'country': 'US'})
Asynchronous Operations
# Create
user = User(name='Jane', email='jane@example.com')
await user.save_async()
# Read
user = await User.find_one_async({'email': 'jane@example.com'})
users = await User.find_async({'age': {'$gte': 25}})
all_users = await User.all_async()
# Update
await User.update_async({'age': {'$lt': 18}}, {'is_minor': True})
# Delete
await User.remove_async({'status': 'inactive'})
# Aggregation
total_age = await User.sum_async('age', {'country': 'US'})
Relationships
class Post(Model):
title: str = StringField()
content: str = StringField()
author_id: str = IDField()
class User(Model):
name: str = StringField()
posts: List[Post] = ListField(model=Post)
# Create related records
user = User(name='John')
await user.save_async()
post = Post(title='Hello', content='World', author_id=user.id)
await post.save_async()
# Access relationships
user_posts = await user.posts # Automatically fetches related posts
Testing
Run the test suite:
pytest tests/
The test suite includes comprehensive tests for:
- All database operations (CRUD)
- Both sync and async operations
- Field validations
- Relationships
- Computed fields
- Aggregations
Requirements
- Python 3.7+
- pydantic >= 2.0.0
- motor >= 3.3.0 (for MongoDB)
- aiopg >= 1.4.0 (for PostgreSQL)
- aiomysql >= 0.2.0 (for MySQL)
- inflect >= 5.0.0
- python-dotenv >= 0.19.0
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
MIT License
Metadata
Release files for odbms 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| odbms-0.5.2.tar.gz | 52.3 kB | Without provenance | Details for odbms-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| odbms-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for odbms-0.5.2-py3-none-any.whl |
Total release size: 102.9 kB
Release files / odbms-0.5.2.tar.gz
| Download URL | odbms-0.5.2.tar.gz |
|---|---|
| Size | 52.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
728e34ca15af777a114b607c9a7b364a104315c0750c02bfe3c3060b812477bf
|
|
BLAKE2b-256 checksum How to use checksums |
659f901869d793fc4da80995b9d269762daac7281b361d0e51c3dabb13136625
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / odbms-0.5.2-py3-none-any.whl
| Download URL | odbms-0.5.2-py3-none-any.whl |
|---|---|
| Size | 50.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3318e2e722067e51bee9fc463ee7201d5a1a38bb928831f3da181bcd4d73ce8c
|
|
BLAKE2b-256 checksum How to use checksums |
d5d6f2edbc3da8922d6d783ce1604901837809a65c8f7a0322a2c019f8f87341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for odbms 0.5.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.