Scroll to navigation

PYDOCUMENTDB(1) pydocumentdb PYDOCUMENTDB(1)

NAME

pydocumentdb - pydocumentdb 2.3.3

SYSTEM REQUIREMENTS:

The supported Python versions are 2.7, 3.3, 3.4 and 3.5. To download Python, please visit https://www.python.org/download/releases.

Python Tools for Visual Studio is required when using Microsoft Visual Studio to develop Python applications. To download Python Tools for Visual Studio, please visit http://microsoft.github.io/PTVS.



INSTALLATION:

Method 1:
1.
Download the Azure DocumentDB Python SDK source from https://github.com/Azure/azure-documentdb-python which is needed to manage the Azure DocumentDB database service.
2.
Execute the following setup script in bash shell:

$ python setup.py install



Method 2:

1.
Install the Azure DocumentDB Python SDK using pip. For more information on pip, please visit https://pypi.python.org/pypi/pip
2.
Execute the following in bash shell:

$ pip install pydocumentdb





TO RUN TESTS:

$ python -m unittest discover -s .\test -p "*.py"


If you use Microsoft Visual Studio, open the project file python.pyproj, and run all the tests in Test Explorer.



TO GENERATE DOCUMENTATIONS:

Install Sphinx: http://sphinx-doc.org/install.html

$ cd doc
$ sphinx-apidoc -f -e -o api ..\pydocumentdb
$ make.bat html




  • genindex
  • modindex
  • search

PYDOCUMENTDB PACKAGE

Subpackages

pydocumentdb.execution_context package

Submodules

pydocumentdb.execution_context.aggregators module

Internal class for aggregation queries implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.base_execution_context module

Internal class for query execution context implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.document_producer module

Internal class for document producer implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.endpoint_component module

Internal class for query execution endpoint component implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.execution_dispatcher module

Internal class for proxy query execution context implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.multi_execution_aggregator module

Internal class for multi execution context aggregator implementation in the Azure Cosmos DB database service.

pydocumentdb.execution_context.query_execution_info module

Internal class for partitioned query execution info implementation in the Azure Cosmos DB database service.

Module contents

pydocumentdb.routing package

Submodules

pydocumentdb.routing.collection_routing_map module

Internal class for collection routing map implementation in the Azure Cosmos DB database service.

pydocumentdb.routing.routing_map_provider module

Internal class for partition key range cache implementation in the Azure Cosmos DB database service.

pydocumentdb.routing.routing_range module

Internal class for partition key range implementation in the Azure Cosmos DB database service.

Module contents

Submodules

pydocumentdb.auth module

Authorization helper functions in the Azure Cosmos DB database service.

Gets the authorization header.
  • document_client (document_client.DocumentClient) --
  • verb (str) --
  • path (str) --
  • resource_id_or_fullname (str) --
  • resource_type (str) --
  • headers (dict) --

The authorization headers.
dict


pydocumentdb.base module

Base functions in the Azure Cosmos DB database service.

Decodes a Base64 encoded string by replacing '-' with '/'
string_to_decode (string) -- String to decode.
Path with beginning and ending slashes trimmed.
str


Gets a random GUID.

Note that here we use python's UUID generation library. Basically UUID is the same as GUID when represented as a string.

The generated random GUID.
str


Gets attachment id from media id.
media_id (str) --
The attachment id from the media id.
str


extract the collection name and collection id

Ever response header has alt-content-path that is the owner's path in ascii. For document create / update requests, this can be used to get the collection name, but for collection create response, we can't use it. So we also rely on


  • self_link (str) -- Self link of the resource, as obtained from response result.
  • alt_content_path (str) -- Owner path of the resource, as obtained from response header.
  • resource_id (str) -- .INDENT 2.0
'id' as returned from the response result. This is only used if it is deduced that the
request was to create a collection.


tuple of (collection rid, collection name)
tuple



Gets the document collection link
link (str) -- Resource link
Document collection link.
str


Gets HTTP request headers.
  • document_client (document_client.DocumentClient) --
  • default_headers (dict) --
  • verb (str) --
  • path (str) --
  • resource_id (str) --
  • resource_type (str) --
  • options (dict) --
  • partition_key_range_id (str) --

The HTTP request headers.
dict


Gets path from resource link with optional resource type
  • resource_link (str) --
  • resource_type (str) --

Path from resource link with resource type appended (if provided).
str


Gets resource id or full name from resource link.
resource_link (str) --
The resource id or full name from the resource link.
str


Gets the index of Nth occurance of a given character in a string
  • s (str) -- Input string
  • value (char) -- Input char to be searched.
  • n (int) -- Nth occurrence of char to be searched.

Index of the Nth occurrence in the string.
int


Finds whether the link is a database Self Link or a database ID based link
link (str) -- Link to analyze
True or False.
boolean


Finds whether the link is a document colllection Self Link or a document colllection ID based link
link (str) -- Link to analyze
True or False.
boolean



Finds whether the link is name based or not
link (str) --
True if link is name-based; otherwise, False.
boolean



Trims beginning and ending slashes
path (str) --
Path with beginning and ending slashes trimmed.
str


pydocumentdb.consistent_hash_ring module

Internal class for consistent hash ring implementation in the Azure Cosmos DB database service.

pydocumentdb.constants module

Class for defining internal constants in the Azure Cosmos DB database service.

pydocumentdb.default_retry_policy module

Internal class for connection reset retry policy implementation in the Azure Cosmos DB database service.

pydocumentdb.document_client module

Document client class for the Azure Cosmos DB database service.

Bases: object

Represents a document client.

Provides a client-side logical representation of the Azure Cosmos DB service. This client is used to configure and execute requests against the service.

The service client encapsulates the endpoint and credentials used to access the Azure Cosmos DB service.

  • url_connection (str) -- The URL for connecting to the DB server.
  • auth (dict) -- Contains 'masterKey' or 'resourceTokens', where auth['masterKey'] is the default authorization key to use to create the client, and auth['resourceTokens'] is the alternative authorization key.
  • connection_policy (documents.ConnectionPolicy) -- The connection policy for the client.
  • consistency_level (documents.ConsistencyLevel) -- The default consistency policy for client operations.


Creates a Azure Cosmos DB resource and returns it.
  • body (dict) --
  • path (str) --
  • type (str) --
  • id (str) --
  • initial_headers (dict) --
  • options (dict) -- The request options for the request.

The created Azure Cosmos DB resource.
dict


Creates an attachment in a document.
  • document_link (str) -- The link to the document.
  • attachment (dict) -- The Azure Cosmos DB attachment to create.
  • options (dict) -- The request options for the request.

The created Attachment.
dict


Creates an attachment and upload media.
  • document_link (str) -- The link to the document.
  • stream object) readable_stream ((file-like) --
  • options (dict) -- The request options for the request.

The created Attachment.
dict


Creates a collection in a database.
  • database_link (str) -- The link to the database.
  • collection (dict) -- The Azure Cosmos DB collection to create.
  • options (dict) -- The request options for the request.

The Collection that was created.
dict


Creates a database.
  • database (dict) -- The Azure Cosmos DB database to create.
  • options (dict) -- The request options for the request.

The Database that was created.
dict


Creates a document in a collection.
  • database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection.
  • document (dict) -- The Azure Cosmos DB document to create.
  • options (dict) -- The request options for the request.
  • options['disableAutomaticIdGeneration'] (bool) -- Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned.

The created Document.
dict


Creates a permission for a user.
  • user_link (str) -- The link to the user entity.
  • permission (dict) -- The Azure Cosmos DB user permission to create.
  • options (dict) -- The request options for the request.

The created Permission.
dict


Creates a stored procedure in a collection.
  • collection_link (str) -- The link to the document collection.
  • sproc (str) --
  • options (dict) -- The request options for the request.

The created Stored Procedure.
dict


Creates a trigger in a collection.
  • collection_link (str) -- The link to the document collection.
  • trigger (dict) --
  • options (dict) -- The request options for the request.

The created Trigger.
dict


Creates a user.
  • database_link (str) -- The link to the database.
  • user (dict) -- The Azure Cosmos DB user to create.
  • options (dict) -- The request options for the request.

The created User.
dict


Creates a user defined function in a collection.
  • collection_link (str) -- The link to the collection.
  • udf (str) --
  • options (dict) -- The request options for the request.

The created UDF.
dict


Deletes an attachment.
  • attachment_link (str) -- The link to the attachment.
  • options (dict) -- The request options for the request.

The deleted Attachment.
dict


Deletes a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request.

The deleted Collection.
dict


Deletes a conflict.
  • conflict_link (str) -- The link to the conflict.
  • options (dict) -- The request options for the request.

The deleted Conflict.
dict


Deletes a database.
  • database_link (str) -- The link to the database.
  • options (dict) -- The request options for the request.

The deleted Database.
dict


Deletes a document.
  • document_link (str) -- The link to the document.
  • options (dict) -- The request options for the request.

The deleted Document.
dict


Deletes a permission.
  • permission_link (str) -- The link to the permission.
  • options (dict) -- The request options for the request.

The deleted Permission.
dict


Deletes a Azure Cosmos DB resource and returns it.
  • path (str) --
  • type (str) --
  • id (str) --
  • initial_headers (dict) --
  • options (dict) -- The request options for the request.

The deleted Azure Cosmos DB resource.
dict


Deletes a stored procedure.
  • sproc_link (str) -- The link to the stored procedure.
  • options (dict) -- The request options for the request.

The deleted Stored Procedure.
dict


Deletes a trigger.
  • trigger_link (str) -- The link to the trigger.
  • options (dict) -- The request options for the request.

The deleted Trigger.
dict


Deletes a user.
  • user_link (str) -- The link to the user entity.
  • options (dict) -- The request options for the request.

The deleted user.
dict


Deletes a user defined function.
  • udf_link (str) -- The link to the user defined function.
  • options (dict) -- The request options for the request.

The deleted UDF.
dict


Executes a store procedure.
  • sproc_link (str) -- The link to the stored procedure.
  • params (dict) -- List or None
  • options (dict) -- The request options for the request.

The Stored Procedure response.
dict


Gets database account info.
The Database Account.
documents.DatabaseAccount


Gets the partition resolver associated with the database link
database_link (str) -- Database self link or ID based link.
An instance of PartitionResolver.
object



Queries attachments in a document.
  • document_link (str) -- The link to the document.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Attachments.
query_iterable.QueryIterable


Queries collections in a database.
  • database_link (str) -- The link to the database.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Collections.
query_iterable.QueryIterable


Queries conflicts in a collection.
  • collection_link (str) -- The link to the document collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Conflicts.
query_iterable.QueryIterable


Queries databases.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Databases.
query_iterable.QueryIterable


Queries documents in a collection.
  • database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.
  • partition_key (str) -- Partition key for the query(default value None)

Query Iterable of Documents.
query_iterable.QueryIterable


Queries documents change feed in a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request. options may also specify partition key range id.

Query Iterable of Documents.
query_iterable.QueryIterable


Query Feed for Document Collection resource.
  • path (str) -- Path to the document collection.
  • collection_id (str) -- Id of the document collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.
  • partition_key_range_id (str) -- Partition key range id.

tuple


Query for all offers.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request

Query Iterable of Offers.
query_iterable.QueryIterable


Queries permissions for a user.
  • user_link (str) -- The link to the user entity.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Permissions.
query_iterable.QueryIterable


Queries stored procedures in a collection.
  • collection_link (str) -- The link to the document collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Stored Procedures.
query_iterable.QueryIterable


Queries triggers in a collection.
  • collection_link (str) -- The link to the document collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Triggers.
query_iterable.QueryIterable


Queries user defined functions in a collection.
  • collection_link (str) -- The link to the collection.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of UDFs.
query_iterable.QueryIterable


Queries users in a database.
  • database_link (str) -- The link to the database.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.

Query Iterable of Users.
query_iterable.QueryIterable


Reads a Azure Cosmos DB resource and returns it.
  • path (str) --
  • type (str) --
  • id (str) --
  • initial_headers (dict) --
  • options (dict) -- The request options for the request.

The upserted Azure Cosmos DB resource.
dict


Reads an attachment.
  • attachment_link (str) -- The link to the attachment.
  • options (dict) -- The request options for the request.

The read Attachment.
dict


Reads all attachments in a document.
  • document_link (str) -- The link to the document.
  • options (dict) -- The request options for the request.

Query Iterable of Attachments.
query_iterable.QueryIterable


Reads a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request.

The read Collection.
dict


Reads all collections in a database.
  • database_link (str) -- The link to the database.
  • options (dict) -- The request options for the request.

Query Iterable of Collections.
query_iterable.QueryIterable


Reads a conflict.
  • conflict_link (str) -- The link to the conflict.
  • options (dict) --

The read Conflict.
dict


Reads conflicts.
  • collection_link (str) -- The link to the document collection.
  • feed_options (dict) --

Query Iterable of Conflicts.
query_iterable.QueryIterable


Reads a database.
  • database_link (str) -- The link to the database.
  • options (dict) -- The request options for the request.

The Database that was read.
dict


Reads all databases.
options (dict) -- The request options for the request.
Query Iterable of Databases.
query_iterable.QueryIterable


Reads a document.
  • document_link (str) -- The link to the document.
  • options (dict) -- The request options for the request.

The read Document.
dict


Reads all documents in a collection.
  • collection_link (str) -- The link to the document collection.
  • feed_options (dict) --

Query Iterable of Documents.
query_iterable.QueryIterable


Gets the curent read endpoint for a geo-replicated database account.

Reads a media.

When self.connection_policy.MediaReadMode == documents.MediaReadMode.Streamed, returns a file-like stream object; otherwise, returns a str.

media_link (str) -- The link to the media.
The read Media.
str or file-like stream object


Reads an offer.
offer_link (str) -- The link to the offer.
The read Offer.
dict


Reads all offers.
options (dict) -- The request options for the request
Query Iterable of Offers.
query_iterable.QueryIterable


Reads a permission.
  • permission_link (str) -- The link to the permission.
  • options (dict) -- The request options for the request.

The read permission.
dict


Reads all permissions for a user.
  • user_link (str) -- The link to the user entity.
  • options (dict) -- The request options for the request.

Query Iterable of Permissions.
query_iterable.QueryIterable


Reads a stored procedure.
  • sproc_link (str) -- The link to the stored procedure.
  • options (dict) -- The request options for the request.

The read Stored Procedure.
dict


Reads all store procedures in a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request.

Query Iterable of Stored Procedures.
query_iterable.QueryIterable


Reads a trigger.
  • trigger_link (str) -- The link to the trigger.
  • options (dict) -- The request options for the request.

The read Trigger.
dict


Reads all triggers in a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request.

Query Iterable of Triggers.
query_iterable.QueryIterable


Reads a user.
  • user_link (str) -- The link to the user entity.
  • options (dict) -- The request options for the request.

The read User.
dict


Reads a user defined function.
  • udf_link (str) -- The link to the user defined function.
  • options (dict) -- The request options for the request.

The read UDF.
dict


Reads all user defined functions in a collection.
  • collection_link (str) -- The link to the document collection.
  • options (dict) -- The request options for the request.

Query Iterable of UDFs.
query_iterable.QueryIterable


Reads all users in a database.
The link to the database.
The request options for the request.
Query iterable of Users.
query_iterable.QueryIterable


Registers the partition resolver associated with the database link
  • database_link (str) -- Database Self Link or ID based link.
  • partition_resolver (object) -- An instance of PartitionResolver.



Replaces a Azure Cosmos DB resource and returns it.
  • resource (dict) --
  • path (str) --
  • type (str) --
  • id (str) --
  • initial_headers (dict) --
  • options (dict) -- The request options for the request.

The new Azure Cosmos DB resource.
dict


Replaces an attachment and returns it.
  • attachment_link (str) -- The link to the attachment.
  • attachment (dict) --
  • options (dict) -- The request options for the request.

The replaced Attachment
dict


Replaces a collection and return it.
  • collection_link (str) -- The link to the collection entity.
  • collection (dict) -- The collection to be used.
  • options (dict) -- The request options for the request.

The new Collection.
dict


Replaces a document and returns it.
  • document_link (str) -- The link to the document.
  • new_document (dict) --
  • options (dict) -- The request options for the request.

The new Document.
dict


Replaces an offer and returns it.
  • offer_link (str) -- The link to the offer.
  • offer (dict) --

The replaced Offer.
dict


Replaces a permission and return it.
  • permission_link (str) -- The link to the permission.
  • permission (dict) --
  • options (dict) -- The request options for the request.

The new Permission.
dict


Replaces a stored procedure and returns it.
  • sproc_link (str) -- The link to the stored procedure.
  • sproc (dict) --
  • options (dict) -- The request options for the request.

The replaced Stored Procedure.
dict


Replaces a trigger and returns it.
  • trigger_link (str) -- The link to the trigger.
  • trigger (dict) --
  • options (dict) -- The request options for the request.

The replaced Trigger.
dict


Replaces a user and return it.
  • user_link (str) -- The link to the user entity.
  • user (dict) --
  • options (dict) -- The request options for the request.

The new User.
dict


Replaces a user defined function and returns it.
  • udf_link (str) -- The link to the user defined function.
  • udf (dict) --
  • options (dict) -- The request options for the request.

The new UDF.
dict


Gets the session object from the client

Updates a media and returns it.
  • media_link (str) -- The link to the media.
  • stream object) readable_stream ((file-like) --
  • options (dict) -- The request options for the request.

The updated Media.
str or file-like stream object


Upserts a Azure Cosmos DB resource and returns it.
  • body (dict) --
  • path (str) --
  • type (str) --
  • id (str) --
  • initial_headers (dict) --
  • options (dict) -- The request options for the request.

The upserted Azure Cosmos DB resource.
dict


Upserts an attachment in a document.
  • document_link (str) -- The link to the document.
  • attachment (dict) -- The Azure Cosmos DB attachment to upsert.
  • options (dict) -- The request options for the request.

The upserted Attachment.
dict


Upserts an attachment and upload media.
  • document_link (str) -- The link to the document.
  • stream object) readable_stream ((file-like) --
  • options (dict) -- The request options for the request.

The upserted Attachment.
dict


Upserts a document in a collection.
  • database_or_collection_link (str) -- The link to the database when using partitioning, otherwise link to the document collection.
  • document (dict) -- The Azure Cosmos DB document to upsert.
  • options (dict) -- The request options for the request.
  • options['disableAutomaticIdGeneration'] (bool) -- Disables the automatic id generation. If id is missing in the body and this option is true, an error will be returned.

The upserted Document.
dict


Upserts a permission for a user.
  • user_link (str) -- The link to the user entity.
  • permission (dict) -- The Azure Cosmos DB user permission to upsert.
  • options (dict) -- The request options for the request.

The upserted permission.
dict


Upserts a stored procedure in a collection.
  • collection_link (str) -- The link to the document collection.
  • sproc (str) --
  • options (dict) -- The request options for the request.

The upserted Stored Procedure.
dict


Upserts a trigger in a collection.
  • collection_link (str) -- The link to the document collection.
  • trigger (dict) --
  • options (dict) -- The request options for the request.

The upserted Trigger.
dict


Upserts a user.
  • database_link (str) -- The link to the database.
  • user (dict) -- The Azure Cosmos DB user to upsert.
  • options (dict) -- The request options for the request.

The upserted User.
dict


Upserts a user defined function in a collection.
  • collection_link (str) -- The link to the collection.
  • udf (str) --
  • options (dict) -- The request options for the request.

The upserted UDF.
dict


Gets the curent write endpoint for a geo-replicated database account.


pydocumentdb.documents module

AzureDocument classes and enums for the Azure Cosmos DB database service.

Bases: object

Represents the connection mode to be used by the client.

Gateway (int) -- Use the Azure Cosmos DB gateway to route all requests. The gateway proxies requests to the right data partition.



Bases: object

Represents the Connection policy assocated with a DocumentClient.

  • RequestTimeout (int) -- Gets or sets the request timeout (time to wait for response from network peer).
  • MediaRequestTimeout (int) -- Gets or sets Time to wait for response from network peer for attachment content (aka media) operations.
  • ConnectionMode (documents.ConnectionMode) -- Gets or sets the connection mode used in the client. Currently only Gateway is supported.
  • MediaReadMode (MediaReadMode.Buffered) -- Gets or sets the attachment content (aka media) download mode.
  • SSLConfiguration (documents.SSLConfiguration) -- Gets or sets the SSL configuration.
  • ProxyConfiguration (documents.ProxyConfiguration) -- Gets or sets the proxy configuration.
  • EnableEndpointDiscovery (boolean) -- Gets or sets endpoint discovery flag for geo-replicated database accounts. When EnableEndpointDiscovery is true, the client will automatically discover the current write and read locations and direct the requests to the correct location taking into consideration of the user's preference(if provided) as PreferredLocations.
  • PreferredLocations (list) -- Gets or sets the preferred locations for geo-replicated database accounts. When EnableEndpointDiscovery is true and PreferredLocations is non-empty, the client will use this list to evaluate the final location, taking into consideration the order specified in PreferredLocations list. The locations in this list are specified as the names of the azure cosmos db locations like, 'West US', 'East US', 'Central India' and so on.
  • RetryOptions (RetryOptions) -- Gets or sets the retry options to be applied to all requests when retrying.
  • DisableSSLVerification (boolean) -- Flag to disable SSL verification for the requests. SSL verification is enabled by default. Don't set this when targeting production endpoints. This is intended to be used only when targeting emulator endpoint to avoid failing your requests with SSL related error.



Bases: object

Represents the consistency levels supported for Azure Cosmos DB client operations.

The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. Consistency levels.

Consistency levels by order of strength are Strong, BoundedStaleness, Session, ConsistentPrefix and Eventual.

  • Strong (str) -- Strong Consistency guarantees that read operations always return the value that was last written.
  • BoundedStaleness (str) -- Bounded Staleness guarantees that reads are not too out-of-date. This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).
  • Session (str) -- Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) within any single session.
  • Eventual (str) -- Eventual Consistency guarantees that reads will return a subset of writes. All writes will be eventually be available for reads.
  • ConsistentPrefix (str) -- ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. All writes will be eventually be available for reads.





Session = 'Session'



Bases: object

Specifies the data type of index specs.

  • Number (str) -- Represents a numeric data type.
  • String (str) -- Represents a string data type.
  • Point (str) -- Represents a point data type.
  • LineString (str) -- Represents a line string data type.
  • Polygon (str) -- Represents a polygon data type.








Bases: object

Database account. A DatabaseAccount is the container for databases.

  • DatabaseLink (str) -- The self-link for Databases in the databaseAccount.
  • MediaLink (str) -- The self-link for Media in the databaseAccount.
  • MaxMediaStorageUsageInMB (int) -- Attachment content (media) storage quota in MBs (Retrieved from gateway).
  • CurrentMediaStorageUsageInMB (int) -- Current attachment content (media) usage in MBs (Retrieved from gateway). Value is returned from cached information updated periodically and is not guaranteed to be real time.
  • ConsistencyPolicy (dict) -- UserConsistencyPolicy settings.
  • ConsistencyPolicy['defaultConsistencyLevel'] (dict) -- The default consistency level.
  • ConsistencyPolicy['maxStalenessPrefix'] (int) -- In bounded staleness consistency, the maximum allowed staleness in terms difference in sequence numbers (aka version).
  • ConsistencyPolicy['maxStalenessIntervalInSeconds'] (int) -- In bounded staleness consistency, the maximum allowed staleness in terms time interval.


Gets the list of readable locations for a geo-replicated database account.

Gets the list of writable locations for a geo-replicated database account.


Bases: object

Specifies the index kind of index specs.

  • Hash (str) -- The index entries are hashed to serve point look up queries. Can be used to serve queries like: SELECT * FROM docs d WHERE d.prop = 5
  • Range (str) -- The index entries are ordered. Range indexes are optimized for inequality predicate queries with efficient range scans. Can be used to serve queries like: SELECT * FROM docs d WHERE d.prop > 5





Bases: object

Specifies whether or not the resource is to be indexed.

  • Default (int) -- Use any pre-defined/pre-configured defaults.
  • Exclude (int) -- Index the resource.
  • Include (int) -- Do not index the resource.






Bases: object

Specifies the supported indexing modes.

  • Consistent (str) --

    Index is updated synchronously with a create or update operation. With consistent indexing, query behavior is the same as the default consistency level for the collection.

    The index is always kept up to date with the data.

  • Lazy (str) --

    Index is updated asynchronously with respect to a create or update operation.

    With lazy indexing, queries are eventually consistent. The index is updated when the collection is idle.

  • NoIndex (str) --

    No index is provided.

    Setting IndexingMode to "None" drops the index. Use this if you don't want to maintain the index for a document collection, to save the storage cost or improve the write throughput. Your queries will degenerate to scans of the entire collection.







Bases: object

Represents the mode for use with downloading attachment content (aka media).

  • Buffered (str) --

    Content is buffered at the client and not directly streamed from the content store.

    Use Buffered to reduce the time taken to read and write media files.

  • Streamed (str) --

    Content is directly streamed from the content store without any buffering at the client.

    Use Streamed to reduce the client memory overhead of reading and writing media files.






Bases: object

Specifies the kind of partitioning to be applied.

Hash (str) -- The partition key definition path is hashed.



Bases: object

Enumeration specifying applicability of permission.

  • NoneMode (str) -- None.
  • Read (str) -- Permission applicable for read operations only.
  • All (str) -- Permission applicable for all operations.






Bases: object

Configurations for proxy.

  • Host (str) -- The host address of the proxy.
  • Port (int) -- The port number of the proxy.



Bases: object

Configurations for SSL connections.

Please refer to http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification for more detail.

  • SSLKeyFIle (str) -- The path of the key file for ssl connection.
  • SSLCertFile (str) -- The path of the cert file for ssl connection.
  • SSLCaCerts (str) -- The path of the CA_BUNDLE file with certificates of trusted CAs.



Bases: object

Specifies the operations on which a trigger should be executed.

  • All (str) -- All operations.
  • Create (str) -- Create operations only.
  • Update (str) -- Update operations only.
  • Delete (str) -- Delete operations only.
  • Replace (str) -- Replace operations only.








Bases: object

Specifies the type of the trigger.

  • Pre (str) -- Trigger should be executed before the associated operation(s).
  • Post (str) -- Trigger should be executed after the associated operation(s).





Bases: object

Represents undefined value for partitionKey when it's mising.


pydocumentdb.endpoint_discovery_retry_policy module

Internal class for endpoint discovery retry policy implementation in the Azure Cosmos DB database service.

pydocumentdb.errors module

PyDocumentDB Exceptions in the Azure Cosmos DB database service.

Bases: Exception

Base class for all Azure Cosmos DB errors.


Bases: pydocumentdb.errors.DocumentDBError

Raised when a HTTP request to the Azure Cosmos DB has failed.

  • status_code (int) --
  • message (str) --



Bases: pydocumentdb.errors.DocumentDBError

Raised when fails to parse JSON message.


Bases: pydocumentdb.errors.DocumentDBError

Raised when unexpected data type is provided as parameter.


pydocumentdb.global_endpoint_manager module

Internal class for global endpoint manager implementation in the Azure Cosmos DB database service.

pydocumentdb.hash_partition_resolver module

Hash partition resolver implementation in the Azure Cosmos DB database service.

Bases: object

HashPartitionResolver implements partitioning based on the value of a hash function, allowing you to evenly distribute requests and data across a number of partitions.

  • partition_key_extractor (lambda) -- Returning the partition key from the document passed.
  • collection_links (list) -- The links of collections participating in partitioning.
  • default_number_of_virtual_nodes_per_collection (int) -- Number of virtual nodes per collection.
  • hash_generator (HashGenerator) -- The hash generator to be used for hashing algorithm.


Resolves the collection for creating the document based on the partition key.
document (dict) -- The document to be created.
Collection Self link or Name based link which should handle the Create operation.
str


Resolves the collection for reading/querying the documents based on the partition key.
document (dict) -- The document to be read/queried.
Collection Self link(s) or Name based link(s) which should handle the Read operation.
list



pydocumentdb.http_constants module

HTTP Constants in the Azure Cosmos DB database service.





Bases: object

Constants of http headers.

























































































































pydocumentdb.murmur_hash module

Internal class for Murmur hash implementation in the Azure Cosmos DB database service.

pydocumentdb.partition module

Internal class for client side partition implementation in the Azure Cosmos DB database service.

pydocumentdb.query_iterable module

Iterable query results in the Azure Cosmos DB database service.

Bases: object

Represents an iterable object of the query results. QueryIterable is a wrapper for query execution context.

Instantiates a QueryIterable for non-client side partitioning queries. _ProxyQueryExecutionContext will be used as the internal query execution context

  • client (DocumentClient) -- Instance of document client.
  • or dict) query ((str) --
  • options (dict) -- The request options for the request.
  • fetch_function (method) --
  • collection_link (str) -- If this is a Document query/feed collection_link is required.


Example of fetch_function:

>>> def result_fn(result):
>>>     return result['Databases']

Represents a client side partitioning query iterable.

This constructor instantiates a QueryIterable for client side partitioning queries, and sets _MultiCollectionQueryExecutionContext as the internal execution context. :param DocumentClient client:

Instance of document client


  • or dict) options ((str) --
  • options (dict) -- The request options for the request.
  • database_link (str) -- Database self link or ID based link
  • partition_key (str) -- Partition key for the query



Returns a block of results with respecting retry policy.

This method only exists for backward compatibility reasons. (Because QueryIterable has exposed fetch_next_block api).

List of results.
list



pydocumentdb.range module

Range class implementation in the Azure Cosmos DB database service.

Bases: object

Represents the Range class used to map the partition key of the document to their associated collection.

Checks if the passed parameter is in the range of this object.

Checks if the passed parameter intersects the range of this object.


pydocumentdb.range_partition_resolver module

Range partition resolver implementation in the Azure Cosmos DB database service.

Bases: object

RangePartitionResolver implements partitioning based on the ranges, allowing you to distribute requests and data across a number of partitions.

  • partition_key_extractor (lambda) -- Returning the partition key from the document passed.
  • partition_map (dict) -- The dictionary of ranges mapped to their associated collection


Resolves the collection for creating the document based on the partition key.
document (dict) -- The document to be created.
Collection Self link or Name based link which should handle the Create operation.
str


Resolves the collection for reading/querying the documents based on the partition key.
document (dict) -- The document to be read/queried.
Collection Self link(s) or Name based link(s) which should handle the Read operation.
list



pydocumentdb.resource_throttle_retry_policy module

Internal class for resource throttle retry policy implementation in the Azure Cosmos DB database service.

pydocumentdb.retry_options module

Class for retry options in the Azure Cosmos DB database service.

Bases: object

The retry options to be applied to all requests when retrying

  • MaxRetryAttemptCount (int) -- Max number of retries to be performed for a request. Default value 9.
  • FixedRetryIntervalInMilliseconds (int) -- Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response.
  • MaxWaitTimeInSeconds (int) -- Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds.






pydocumentdb.retry_utility module

Internal methods for executing functions in the Azure Cosmos DB database service.

pydocumentdb.runtime_constants module

Runtime Constants in the Azure Cosmos DB database service.


pydocumentdb.session module

Session Consistency Tracking in the Azure Cosmos DB database service.

Bases: object

State of a Azure Cosmos DB session. This session object can be shared across clients within the same process




Bases: object
Get Session Token for collection_link
resource_path (str) -- Self link / path to the resource
Session Token dictionary for the collection_id
dict


Extracts session token from response headers and parses
response_headers (dict) --
A dictionary of partition id to session lsn for given collection
dict


Session token must only be updated from response of requests that successfully mutate resource on the server side (write, replace, delete etc)
  • response_result (dict) --
  • response_headers (dict) --

None




pydocumentdb.synchronized_request module

Synchronized request in the Azure Cosmos DB database service.

Performs one synchronized http request according to the parameters.
  • client (object) -- Document client instance
  • global_endpoint_manager (_GlobalEndpointManager) --
  • connection_policy (documents.ConnectionPolicy) --
  • requests_session (requests.Session) -- Session object in requests module
  • method (str) --
  • base_url (str) --
  • path (str) --
  • unicode, file-like stream object, dict, list or None) request_data ((str,) --
  • query_params (dict) --
  • headers (dict) --

tuple of (result, headers)
tuple of (dict dict)


pydocumentdb.utils module

Internal Helper functions in the Azure Cosmos DB database service.

Module contents

PYDOCUMENTDB

COPYRIGHT

2019, Microsoft

November 20, 2019 2.3.3