Пример #1
0
    def execute(self, context: "Context") -> None:
        # Create the hook
        hook = AzureCosmosDBHook(azure_cosmos_conn_id=self.azure_cosmos_conn_id)

        # Create the DB if it doesn't already exist
        if not hook.does_database_exist(self.database_name):
            hook.create_database(self.database_name)

        # Create the collection as well
        if not hook.does_collection_exist(self.collection_name, self.database_name):
            hook.create_collection(self.collection_name, self.database_name)

        # finally insert the document
        hook.upsert_document(self.document, self.database_name, self.collection_name)
Пример #2
0
 def poke(self, context: "Context") -> bool:
     self.log.info("*** Entering poke")
     hook = AzureCosmosDBHook(self.azure_cosmos_conn_id)
     return hook.get_document(self.document_id, self.database_name,
                              self.collection_name) is not None