diff --git a/DocumentDBGetStarted.py b/DocumentDBGetStarted.py index c8af297..dbb6f7a 100644 --- a/DocumentDBGetStarted.py +++ b/DocumentDBGetStarted.py @@ -1,4 +1,3 @@ -import pydocumentdb; import pydocumentdb.document_client as document_client config = { @@ -6,10 +5,13 @@ 'MASTERKEY': 'FILLME', 'DOCUMENTDB_DATABASE': 'db', 'DOCUMENTDB_COLLECTION': 'coll' -}; +} # Initialize the Python DocumentDB client -client = document_client.DocumentClient(config['ENDPOINT'], {'masterKey': config['MASTERKEY']}) +client = document_client.DocumentClient( + config['ENDPOINT'], + {'masterKey': config['MASTERKEY']} +) # Create a database db = client.CreateDatabase({ 'id': config['DOCUMENTDB_DATABASE'] }) @@ -22,7 +24,11 @@ } # Create a collection -collection = client.CreateCollection(db['_self'], { 'id': config['DOCUMENTDB_COLLECTION'] }, options) +collection = client.CreateCollection( + db['_self'], + { 'id': config['DOCUMENTDB_COLLECTION'] }, + options +) # Create some documents document1 = client.CreateDocument(collection['_self'], @@ -32,7 +38,8 @@ 'Cloud Service': 0, 'Virtual Machine': 0, 'name': 'some' - }) + } +) document2 = client.CreateDocument(collection['_self'], { @@ -41,16 +48,17 @@ 'Cloud Service': 0, 'Virtual Machine': 0, 'name': 'some' - }) + } +) # Query them in SQL -query = { 'query': 'SELECT * FROM server s' } +query = { 'query': 'SELECT * FROM server' } options = {} options['enableCrossPartitionQuery'] = True options['maxItemCount'] = 2 result_iterable = client.QueryDocuments(collection['_self'], query, options) -results = list(result_iterable); +results = list(result_iterable) print(results)