Skip to main content

Asynchronous ODM (Object Document Mapper) for MongoDB

Project description

bilu

Asynchronous ODM (Object Document Mapper) for MongoDB

Requirements

Python: 3.6 and later (tested against 3.6, 3.7, 3.8 and 3.9)

MongoDB: 4.0 and later

pydantic: 1.8.2 and later

Two direct dependencies:

  • pydantic: makes data validation and schema definition both handy and elegant.

  • motor: an asyncio MongoDB driver officially developed by the MongoDB team.

Installation

pip install Bilu

Environments

export MONGODB_URI='mongodb://localhost:27017'
export MONGODB_USERNAME=''
export MONGODB_PASSWORD=''
export MONGODB_DATABASE='test'
export MONGODB_MIN_POOL_SIZE=0
export MONGODB_MAX_POOL_SIZE=100

Example

Connecting to mongodb

from bilu.database import db_manager
db_manager.connect()

Define model

from bilu.model import BaseModel

class TesteModel(BaseModel):
    attr_str: str
    attr_int: int

    class Meta:
        name = 'testemodel'

Creating a document

data = {
    'attr_str': 'bla',
    'attr_int': 123
}
model = TesteModel(**data)
await model.save()

Listing documents

await model.documents.list(attr_int=123)

Getting a document

item = await model.documents.get(attr_int=123)

Removing a document

await item.delete()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Bilu-0.0.3-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file Bilu-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: Bilu-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.2

File hashes

Hashes for Bilu-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 570891924bbdfb6cfa2862b277cbf63ebfbfe022b61409f227893b4d9ca89889
MD5 95b26369090cfdd69558f462b4444337
BLAKE2b-256 92e9bc2591ce5306542d0c4b64aac4cdf6375b94fbe8876e6ff55c97273ae617

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page