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

Uploaded Source

File details

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

File metadata

  • Download URL: MDBDict-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 ae9fe3b6e67c8141ea3657f53d57ab70952d5b24d6c9e21522fa0bf22890f7bf
MD5 2e5f3a3bee5e0eade39350d5bc449e71
BLAKE2b-256 bb94cbe483f88215e3f6a23ef7f90dae52c25aab8ed6e53e39fa4a740edfdef7

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