Skip to main content

a python wrapper for the python client of Azure DocumentDB

Project description

A simple python wrapper for the python client of Azure DocumentDB


Using pip:

pip install pyzure_documentdb


Credential file is needed. Create contains secret things.:

DOCUMENTDB_KEY = '!@#!@#!@#YOUR_SECRET_KEY!@#!@#!@#'

Import and initiate:

import credentials
from pyzure_docdb.documentdb import DocumentDB

docdb = DocumentDB(credentials)


Get a database or a collection with each id:

db = docdb.get_database('mydb')
coll = docdb.get_collection('mydb', 'mycoll')

Get a single document with a series of id (database - collection - document):

doc = docdb.get_document('mydb', 'mycoll', 'mydoc')

Or Get all documents:

docs = docdb.get_documents('mydb', 'mycoll')


Query with your custom sql:

sql = 'SELECT * FROM c WHERE c.type=1'
docs = docdb.query_documents('mydb', 'mycoll', sql)


Create a database, a collection by its id:

newdb = docdb.create_db('mynewdb')
newcoll = docdb.create_collection('mynewdb', 'mynewcoll')

Create a document giving a dictionary:

data = {'field1': 'value1', 'field2': 'value2'}
newdoc = docdb.create_document('mynewdb', 'mynewcoll', data)

Upsert (update or insert) a document:

doc = docdb.upsert_document('mynewdb', 'mynewcoll', data)


Replace a document by modifying the original one:

doc = docdb.get_document('mydb', 'mycoll', 'mydoc')
doc['type'] = 3


Empty a collection by deleting all documents of the collection:

docdb.empty_documents('mydb', 'mycoll')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page