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.py  # where '/models/test_model.py' is your file path and file name

# ============== or ===============

generate-authmodel /models/user.py # creates an authenticatable model
  1. It will generate a file like this:
#A MongoDB model for the tests collection
from mdb_models.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-2.9.8.tar.gz (5.5 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-2.9.8-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mdb_models-2.9.8.tar.gz
Algorithm Hash digest
SHA256 8061ce3591ad1d8e022ca3178f74435cac7ce6fb4503b1d2820093ee0c24f83a
MD5 d1fa478e2f0d996f5fa8961e79da27c6
BLAKE2b-256 a142aa7251c6d9a5f6f7c53b503ebccef927780c1f89351e538885eca6bfca2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mdb_models-2.9.8-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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-2.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c29105f80e1c0f79ff7d1df65cd50c7a05ce7d65e91021dd074dbce1210a327a
MD5 6ffa018e4db77ff83d84171f5d608eaf
BLAKE2b-256 1c56c1296ca5df97aa6fc341507f67433025bd509ff200115c2792c234ee2e96

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