Skip to main content

MongORM

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

Metadata

Release files for python-mongorm 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-mongorm 0.1.1
File Size Uploaded
python_mongorm-0.1.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-mongorm 0.1.1
File Interpreter ABI Platform
python_mongorm-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.9 kB

Release files / python_mongorm-0.1.1.tar.gz

Download URL python_mongorm-0.1.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
860328ead59386f17acf085c1efc491df0b7dba0e3e0d0085b347fcbab0989bc
BLAKE2b-256 checksum
How to use checksums
3a230a552d9ae0f771a994f842d6080a6f79c9c52af9d655bd1e2014bff6d8c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0rc1 Linux/6.2.7-060207-generic

Release files / python_mongorm-0.1.1-py3-none-any.whl

Download URL python_mongorm-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed0e7f3aa723ac41818b622f6ca993bcc2dd157f584ac7bea0453b2f3c291cb1
BLAKE2b-256 checksum
How to use checksums
ed40c16fc1c562a75dca5abe76cb7daf2c76b835502bf97bbdd3fbc87bc0d4eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0rc1 Linux/6.2.7-060207-generic

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page