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

Usage

Opening a cluster

import mdict 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.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: MDBDict-1.0.1.tar.gz
  • Upload date:
  • Size: 3.5 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.1.tar.gz
Algorithm Hash digest
SHA256 8b0e10175cf1d0d1cc78ae62af661b4dafd90274995c7aefc9b59f193c4881a9
MD5 92b3ff4e936bdc6a5748e88178dde6d0
BLAKE2b-256 d271620d141572e40a07929ad826079ee86c733112df1d4cbddcc778f71c167e

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