MongoDB Data Layer
A data modeling MongoDB library for Python
Installation
- Install the python package via pip:
pip install mongodb-data-layer
Note: It is better to create a python virtual environment...
-
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"
MONGO_DB_NAME="my_database"
-
To create a model you can simply enter this command on a command promt:
generate-model /models/test_model.py
- It will generate a file like this:
from mongodb_data_layer.base import BaseMongoModel
class Test(BaseMongoModel):
collection_name = 'tests'
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