Skip to main content

A wrapper for Pymongo that turns clusters into auto-updating dictionaries

Project description

MDBDict

MDBDict allows you to access MongoDB databases through an automatically updating dictionary

Installation

To install, run the following command:

pip install mdbdict

Alternatively, you can download the source code and install it yourself:

git clone https://github.com/trigtbh/mdbdict.git
cd mdbdict
pip install -r requirements.txt
python setup.py install

Usage

Opening a cluster

import mdbdict as md
db = md.MDict('mongodb://localhost:27017/') # Replace with your MongoDB URI

The contents of the cluster specified by your URI will be loaded into the dictionary.


Displaying the contents of a collection

collection = db['database']['collection'] # Collections are treated as lists of dictionaries
# The first key is the name of the database
# The second key is the name of the specific collection within the database
print(collection)

Adding a document to a collection

collection.append({"_id": 1, "name": "John Doe"})

Editing a document in a collection

document = collection[0]
document["name"] = "Jane Doe" # This change will be automatically saved to MongoDB

Deleting a document in a collection

del collection[0]

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

MDBDict-1.0.4.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file MDBDict-1.0.4.tar.gz.

File metadata

  • Download URL: MDBDict-1.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.1

File hashes

Hashes for MDBDict-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7d8427d56dbdfd959cf1a7e01687d636eab70e01b0bb18e596ed8c32d398dfb9
MD5 1481e2facd7fdc8bb2ae3021cb4d8590
BLAKE2b-256 5a1e88928aea98a8b9b65c3ae5fceb9c0d3967f46ce848c2a94260e2f009b350

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