Skip to main content

MongoDriver

An object-oriented package for interacting with MongoDB documents

Features

  • Object-oriented
  • Update documents without needing to use json
  • Use pymongo within the package as well
  • Built with type hints
  • Removes a lot of boilerplate code
  • So simple it works like ✨magic ✨

Quickstart

Install MongoDriver python3 -m pip install mongodriver

from mongodriver import Driver

driver = Driver(
    connection_url="mongodb+srv://example:SecurePassword@testcluster.e2lhq.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
    db_name="example_db", collection_name="example_collection")

Examples

Here is a basic example on how to create a new document and then interact it

from mongodriver import Driver

driver = Driver(
    connection_url="mongodb+srv://example:SecurePassword@testcluster.e2lhq.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
    db_name="example_db", collection_name="example_collection")

new_document = driver.create({"foo": 1, "bar": 2})

# print the value of "foo"
print(new_document.foo)  # 1

# change the value of "foo"
new_document.foo = 2
print(new_document.foo)  # 2

# OR

new_document.set({"foo": 2})

# you can also change the value of an attribute with the Driver.Variable.update() method

new_document.foo.update(3)

print(new_document.foo)  # 3

Find a document

from mongodriver import Driver

driver = Driver(
    connection_url="mongodb+srv://example:SecurePassword@testcluster.e2lhq.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
    db_name="example_db", collection_name="example_collection")

search_query = {"foo": 1}
documents = driver.find(search_query)  # returns a list of documents
# or driver.find_one(search_query) to get only one document
for document in documents:
    print(document)

Add more keys into a document

from mongodriver import Driver

driver = Driver(
    connection_url="mongodb+srv://example:SecurePassword@testcluster.e2lhq.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
    db_name="example_db", collection_name="example_collection")

json_document = {"foo": 1, "bar": 2}
new_document = driver.create(json_document)

new_document.set({"new_val1": 15, "new_val2": 10})

# OR

new_document.new_val1 = 15
new_document.new_val2 = 10

print(new_document)

Metadata

Release files for mongodriver 1.3.4

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

Source distribution (sdist)

Source distribution for mongodriver 1.3.4
File Size Uploaded Provenance Actions
mongodriver-1.3.4.tar.gz 6.9 kB Without provenance Details for mongodriver-1.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mongodriver 1.3.4
File Interpreter ABI Platform Actions
mongodriver-1.3.4-py3-none-any.whl Python 3 none any Details for mongodriver-1.3.4-py3-none-any.whl

Total release size: 15.0 kB

Release files / mongodriver-1.3.4.tar.gz

Download URL mongodriver-1.3.4.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3814090d13aaed2ed61fbc97b77b8b2702e046f78f6844b6243e233d8ddbcb73
BLAKE2b-256 checksum
How to use checksums
2d2b2eccfed5790bf11cb9f0eb484b659a7ff65fc627a670fb0afb3fb2c1a724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.16 tqdm/4.62.3 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.17

Release files / mongodriver-1.3.4-py3-none-any.whl

Download URL mongodriver-1.3.4-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee68e8ed64695aa79934ee57d6f53830cbceae1ebdc490ca9ec63c1cdeaca70c
BLAKE2b-256 checksum
How to use checksums
a56fae6ec24943159100ae4f4c19fe6bf2257ddafc4632e3cf256eff8be69a50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.28.0 requests-toolbelt/0.9.1 urllib3/1.26.16 tqdm/4.62.3 importlib-metadata/4.10.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.17

Security for mongodriver 1.3.4

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