Skip to main content

A data mapper for mongodb (Formerly mongodb_data_layer)

Project description

MongoDB Data Layer

A data modeling MongoDB library for Python


Installation

  1. Install the python package via pip:
pip install mdb-models

Note: It is better to create a python virtual environment...

  1. Setup an environment variables:

    • To create an environment variables, simply create a file named ".env".
    • Then, add these following variables to a created file:
    MONGO_DB_URL="mongodb://localhost:27020" # The default mongodb localhost but you can also put a connection string from atlas server.
    MONGO_DB_NAME="my_database" # Your created database
    
  2. To create a model you can simply enter this command on a command promt:

generate-model /models/test_model.py  # where '/models/test_model.py' is your file path and file name
  1. It will generate a file like this:
#A MongoDB model for the tests collection
from mongodb_data_layer.base import BaseMongoModel

class Test(BaseMongoModel):
    
    collection_name = 'tests' # Create a collection with this name in the database

Notes

This library is very useful to lessen the configuration for mongodb database.

This package is build on top of MongoDB official package/drivers.

This is also works well in fastapi.

This library is currently in development. Feel free to contribute.


Official repository: https://github.com/nojram00/mongodb-data-layer

Project details


Download files

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

Source Distribution

mdb_models-1.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdb_models-1.3-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file mdb_models-1.3.tar.gz.

File metadata

  • Download URL: mdb_models-1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdb_models-1.3.tar.gz
Algorithm Hash digest
SHA256 aea8c6932a93ef16c57b75bde45c1b2bf8d9919896f8c388f29d2665cfe751cc
MD5 055308e56b68f682def874faf5b61947
BLAKE2b-256 d19ab62f4c46105b31aa393a0bb210fd6dc5a6faab8ae0044b471e55203177b6

See more details on using hashes here.

File details

Details for the file mdb_models-1.3-py3-none-any.whl.

File metadata

  • Download URL: mdb_models-1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdb_models-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 15ec803e6fd5e0bd6179ebabeb5e826132428c1e7357c16b5d2d98ef4e17eda2
MD5 9ba235af8ebe86f66725f79cb86fb60e
BLAKE2b-256 5a62a2ae8a08c53a1405b042bfabdcca0fa41424ea588c1fc995f26430099b5d

See more details on using hashes here.

Supported by

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