airflow.contrib.hooks.azure_cosmos_hook

Module Contents

class airflow.contrib.hooks.azure_cosmos_hook.AzureCosmosDBHook(azure_cosmos_conn_id='azure_cosmos_default')[source]

Bases: airflow.hooks.base_hook.BaseHook

Interacts with Azure CosmosDB.

login should be the endpoint uri, password should be the master key optionally, you can use the following extras to default these values {“database_name”: “<DATABASE_NAME>”, “collection_name”: “COLLECTION_NAME”}.

Parameters

azure_cosmos_conn_id (str) – Reference to the Azure CosmosDB connection.

get_conn(self)[source]

Return a cosmos db client.

__get_database_name(self, database_name=None)[source]
__get_collection_name(self, collection_name=None)[source]
does_collection_exist(self, collection_name, database_name=None)[source]

Checks if a collection exists in CosmosDB.

create_collection(self, collection_name, database_name=None)[source]

Creates a new collection in the CosmosDB database.

does_database_exist(self, database_name)[source]

Checks if a database exists in CosmosDB.

create_database(self, database_name)[source]

Creates a new database in CosmosDB.

delete_database(self, database_name)[source]

Deletes an existing database in CosmosDB.

delete_collection(self, collection_name, database_name=None)[source]

Deletes an existing collection in the CosmosDB database.

upsert_document(self, document, database_name=None, collection_name=None, document_id=None)[source]

Inserts a new document (or updates an existing one) into an existing collection in the CosmosDB database.

insert_documents(self, documents, database_name=None, collection_name=None)[source]

Insert a list of new documents into an existing collection in the CosmosDB database.

delete_document(self, document_id, database_name=None, collection_name=None)[source]

Delete an existing document out of a collection in the CosmosDB database.

get_document(self, document_id, database_name=None, collection_name=None)[source]

Get a document from an existing collection in the CosmosDB database.

get_documents(self, sql_string, database_name=None, collection_name=None, partition_key=None)[source]

Get a list of documents from an existing collection in the CosmosDB database via SQL query.

Was this entry helpful?