Skip to content

Candloid/dbClient

Repository files navigation

dbClient

MongoDB client to connect to AWS DocumentDB

Instantiate a connection

connectionSettings = {
    "dbusername": "someUser",
    "dbpassword": "somePassword",
    "dbname": "someDB",
    "host": "aws",
    "port": 27017,
    "tls": "False",
    "verbose": "True",
    "aws": {
        "clustername": "cluster",
        "node": "node",
        "serverlocation": "us-west-2",
        "replicaSet": "rs0",
        "readPreference": "secondaryPreferred"
    }
}

mongoConnection = dbClient(connectionSettings)

Establish connection through a dbClient client with the proper conenction settings

mongoConnection = dbClient(connectionSettings)

Sets the collection to someCollection

mongoConnection.setTargetCollection('someCollection')

Insert a single document

pythonmongoConnection.insertDoc({'hello': 'world'})

Read a single document

retreivedDoc = mongoConnection.findDoc({'hello': 'world'})

Remove a single document

mongoConnection.removeDoc(retreivedDoc)

Insert multiple documents all at once

mongoConnection.insertDoc(docs, many=True)

Read multiple documents all at once

mongoConnection.findDoc({"hello": "woorld"}, many=True)

Remove multiple documents based on a filter

mongoConnection.removeDoc({"hello": "woorld"}, many=True)

Close database

mongoConnection.closeDB()

About

A Python-based database connection manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages