Skip to main content

DocumentDB (https://documentdb.io/) client for CPython and MicroPython.

Support platform

Install

CPython

$ python3 -m pip install nmongo

or copy https://raw.githubusercontent.com/nakagami/nmongo/master/nmongo.py to python path directry.

MicroPython

Go interactive shell and install with mip as follow.

>>> import mip
>>> mip.install("datetime")
>>> mip.install("ssl")
>>> mip.install("https://raw.githubusercontent.com/nakagami/nmongo/master/nmongo.py")

Example

Connect to DocumentDB

>>> import nmongo
>>> db = nmongo.connect('server', 'somewhatdatabase', user='xxx', password='password', port=10255)
>>>

Create

>>> db.fruits.insert({'name': 'apple', 'price': 200})
1
>>> db.fruits.insert([{'name': 'orange', 'price': 100}, {'name': 'banana', 'price': 50}])
2
>>> db.fruits.count()
3
>>>

Read

>>> cur = db.fruits.find({'name': 'banana'})
>>> cur.fetchone()
{'price': 50, '_id': ObjectId("5826b2313d28909ce9f6ea63"), 'name': 'banana'}
>>> cur = db.fruits.find()
>>> cur.fetchall()
[{'price': 200, '_id': ObjectId("5826b2273d28909ce9f6ea61"), 'name': 'apple'}, {'price': 100, '_id': ObjectId("5826b2313d28909ce9f6ea62"), 'name': 'orange'}, {'price': 50, '_id': ObjectId("5826b2313d28909ce9f6ea63"), 'name': 'banana'}]
>>>

Update

>>> db.fruits.update({'name': 'banana'}, {'$inc': {'price': 20}})
{'nModified': 1, 'ok': 1, 'n': 1}
>>> cur = db.fruits.find({'name': 'banana'})
>>> cur.fetchone()
{'_id': ObjectId("5823dd6d3d28909ce9f6e99c"), 'name': 'banana', 'price': 70}
>>>

Delete

>>> db.fruits.remove({'name': 'banana'})
1
>>> db.fruits.count()
2

Count each collection records

>>> for collection in db.getCollections():
...     print(collection.name, collection.count())
...
fruits 3
>>> db.getCollection('fruits').count()
3
>>>

Features Not Implemented

  • GridFS

Metadata

Release files for nmongo 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nmongo 0.7.0
File Size Uploaded Provenance Actions
nmongo-0.7.0.tar.gz 11.8 kB Without provenance Details for nmongo-0.7.0.tar.gz

Release files / nmongo-0.7.0.tar.gz

Download URL nmongo-0.7.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d343e6c0d638766542daf42c473d6011a67f08e99b646609a7b48c40bc5a6c5c
BLAKE2b-256 checksum
How to use checksums
f2a59d23627d5db3936137ff15ab6a02babd877b25da0d53458ad5e245cd4b7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for nmongo 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page