MongORM is an ORM (object relational mapping) wrapper using async library motor for MongoDB connection and pydantic for data definition and validation.
Project description
MongORM
MongORM is an ORM (object relational mapping) wrapper using async library motor for MongoDB connection and pydantic for data definition and validation.
This module is a work in progress and API may change radically.
MongORM uses pydantic for data validation
and motor for async MongoDB connection.
Installation
Using PIP:
pip install python-mongorm
Using poetry:
poetry add python-mongorm
Usage
Create client
from mongorm import MongORM
client = MongORM("mongodb://root:root@localhost:27017/", "database")
Define model
from mongorm import BaseModel, MongoIndex, MongoIndexType
class Book(BaseModel):
"""Define models the way you would define pydantic models"""
class Meta:
"""Meta contains the model's configuration and indexes"""
client = client # pass the client to the model's Meta
collection = "books"
title = MongoIndex("title", MongoIndexType.ASCENDING)
author = MongoIndex("author", MongoIndexType.ASCENDING)
# id field of type ObjectId is created automatically
title: str
author: str
year_published: int
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_mongorm-0.1.1.tar.gz.
File metadata
- Download URL: python_mongorm-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0rc1 Linux/6.2.7-060207-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
860328ead59386f17acf085c1efc491df0b7dba0e3e0d0085b347fcbab0989bc
|
|
| MD5 |
0bca6da144bc768b2810664647020a48
|
|
| BLAKE2b-256 |
3a230a552d9ae0f771a994f842d6080a6f79c9c52af9d655bd1e2014bff6d8c6
|
File details
Details for the file python_mongorm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: python_mongorm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.11.0rc1 Linux/6.2.7-060207-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed0e7f3aa723ac41818b622f6ca993bcc2dd157f584ac7bea0453b2f3c291cb1
|
|
| MD5 |
7d4ea9fe4d776c9b4b3ff4442568061d
|
|
| BLAKE2b-256 |
ed40c16fc1c562a75dca5abe76cb7daf2c76b835502bf97bbdd3fbc87bc0d4eb
|