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.2.tar.gz
(3.5 kB
view details)
File details
Details for the file MDBDict-1.0.2.tar.gz.
File metadata
- Download URL: MDBDict-1.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3519ca6426f44edbf1147b0b4e74cd6e41bb3c64cfeb4298a7dfc5d6ee2d0f89
|
|
| MD5 |
c2ad2b4c0a10d21f626fee7fb4dde76f
|
|
| BLAKE2b-256 |
69ec87f5425a72c8888d1cd9cba1e9b5fdedd922104b88e3547c0c1d2a447d7f
|