Comprehensive ODM for MongoDB
Mongotoy is a comprehensive Object-Document Mapper (ODM) that streamlines interactions with MongoDB databases in Python applications. Powered by Motor driver, Mongotoy seamlessly integrates with MongoDB, offering a versatile toolkit for constructing high-performance applications. This integration facilitates efficient communication with MongoDB databases, guaranteeing optimal scalability and responsiveness. With Mongotoy, you can unlock the full potential of MongoDB's features.
Features
-
Asynchronous Power: Mongotoy leverages the asynchronous paradigm of Python, enabling efficient management of I/O operations for optimal performance and responsiveness in applications.
-
Based on Motor Driver: Mongotoy is built on top of the asynchronous Motor MongoDB driver, ensuring seamless integration with asynchronous Python applications.
-
Schemaless Flexibility: With a schemaless design, Mongotoy empowers developers to work with MongoDB databases without rigid schemas, adapting to evolving data models effortlessly.
-
Intuitive API: Mongotoy features an elegant and straightforward API facilitating common database operations.
-
Flexible Configuration Options: Mongotoy offers extensive configuration options at both the database and document levels, enabling fine-tuning of MongoDB interactions for optimal performance and reliability.
-
Custom Data Types Support: Mongotoy simplifies handling of custom data types and allows defining new types through Data Mapper classes, enhancing data integrity and consistency.
-
Object-Document Mapping: Simplifying MongoDB document manipulation, Mongotoy maps Python objects to MongoDB documents seamlessly, enabling intuitive and object-oriented interactions.
-
Document Serialization: Mongotoy supports serialization of documents into JSON, BSON, or Python dictionaries, enabling seamless integration with different parts of an application stack.
-
Document Inheritance Support: Mongotoy provides robust support for document inheritance, enabling the creation of hierarchical data models and promoting code reuse and maintainability.
-
Python Type Hint Support: Mongotoy allows developers to define document fields using Python type hints, enhancing code readability and enabling type checking.
-
Relationship Management: Simplifying relationship management between documents, Mongotoy offers robust support for references and embedded documents, automating insertions, deletions, and updates.
-
Automatic Operation Handling: Mongotoy automates insertion and deletion management, ensuring data integrity and consistency across related documents.
-
Query Building: Mongotoy provides a powerful query building interface for constructing complex queries using Pythonic syntax.
-
Index Management: Mongotoy simplifies the management of database indexes, optimizing query performance for efficient data retrieval.
-
Transactions: Supporting MongoDB transactions, Mongotoy ensures data consistency and atomicity across multiple operations within a single transactional context.
-
Geospatial Data Support: Mongotoy offers robust support for geospatial data types, facilitating storage, querying, and spatial analysis.
-
Database Seeding Management: With built-in support for database seeding, Mongotoy streamlines the initialization of databases with predefined data sets, enhancing developer productivity.
-
Support for Capped Collections: Mongotoy natively supports capped collections in MongoDB, ideal for scenarios requiring fixed-size, ordered datasets.
-
Time Series Collections Management: Mongotoy provides robust support for managing time series data in MongoDB, optimized for storing and querying time-stamped data points.
-
GridFS File Handling: Mongotoy seamlessly integrates with MongoDB's GridFS storage system for efficient handling of large files, offering a high-level interface for file management within MongoDB.
Minimal Example
Let's begin with a minimal example by defining a document and performing CRUD operations on the database.
import asyncio
from mongotoy import Document, Engine
import datetime
class Person(Document):
name: str
last_name: str
dob: datetime.date
# Create database engine
db = Engine('test-db')
async def main():
# Create a new Person instance
person = Person(
name='John',
last_name='Doe',
dob=datetime.date(1990, 12, 25)
)
# Connect to the MongoDB database
await db.connect('mongodb://localhost:27017')
# Open a database session
async with db.session() as session:
# Save the person to the database
await session.save(person)
# Fetch all persons from database
async for c in session.objects(Person):
print(c.dump_dict())
# Update person dob
person.dob=datetime.date(1995, 10, 25)
await session.save(person)
# Delete person from database
await session.delete(person)
if __name__ == '__main__':
asyncio.run(main())
Installing
To install, just run:
pip install mongotoy
Or, if using poetry:
poetry add mongotoy
Extras
See full documentation at: https://gurcuff91.github.io/mongotoy
If you like this project !!
Metadata
Release files for mongotoy 0.1.7
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 |
|---|---|---|---|---|
| mongotoy-0.1.7.tar.gz | 36.4 kB | Without provenance | Details for mongotoy-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mongotoy-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for mongotoy-0.1.7-py3-none-any.whl |
Total release size: 77.3 kB
Release files / mongotoy-0.1.7.tar.gz
| Download URL | mongotoy-0.1.7.tar.gz |
|---|---|
| Size | 36.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
504cbb389a5d32852b4ac7549335aad86a96e158888e3d29036967cdd1b35df6
|
|
BLAKE2b-256 checksum How to use checksums |
7809812d4a4a04b1bfebb890c4c079f04aef508c63074baa73c0a6507afde1f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Windows/11
|
Release files / mongotoy-0.1.7-py3-none-any.whl
| Download URL | mongotoy-0.1.7-py3-none-any.whl |
|---|---|
| Size | 40.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53f142c46954bf300f853de955596e17e4f4a69afacb287cf7a57a2978a273fb
|
|
BLAKE2b-256 checksum How to use checksums |
0a02b5c5440f20623f06fe06a119790da2aef8238a626950911f442c42bdb7da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.3 Windows/11
|
Security for mongotoy 0.1.7
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.