Skip to main content

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

Project description

MDict

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

Uploaded Source

File details

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

File metadata

  • Download URL: MDBDict-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 85e73af06d16f31225561064fc303a0d2ce40f3640d825d88165cd1aaf74b859
MD5 6ffc582a77560bfb09694a7b4afa80ac
BLAKE2b-256 7e29c0440822dafa9cf38ff0085fbb1b6e2c71b857954851f415d81de4cf74eb

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