Skip to main content

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

Metadata

Release files for mdb-models 3.0.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 mdb-models 3.0.1
File Size Uploaded
mdb_models-3.0.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdb-models 3.0.1
File Interpreter ABI Platform
mdb_models-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / mdb_models-3.0.1.tar.gz

Download URL mdb_models-3.0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0b599aac092a648be8777ae9e90658086e6fb1946929fbb79c8329bf72990567
BLAKE2b-256 checksum
How to use checksums
34de40f9424d304e4aca38ad375bceb09e4adda1f8888e86f9ef2afa0cacdced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / mdb_models-3.0.1-py3-none-any.whl

Download URL mdb_models-3.0.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ed1c724fedb07e1db4eb1c4730d7bed3178a2b97dc83112d1378ef7240d7ac4
BLAKE2b-256 checksum
How to use checksums
8b8d047034100b13e788611da43294a13be6c57f0e6572569a5fe6a0e95abfc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.9.9

2 release files

2.9.8

2 release files

2.9.7

2 release files

2.9.6

2 release files

2.9.5

2 release files

2.9.4

2 release files

2.9.3

2 release files

2.9.2

2 release files

2.9.1

2 release files

2.9

2 release files

2.8

2 release files

2.7

2 release files

2.6

2 release files

2.5

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

1.9

2 release files

1.8

2 release files

1.7

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

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