當前位置: 首頁>>代碼示例>>Python>>正文


Python BaseHook.get_hook方法代碼示例

本文整理匯總了Python中airflow.hooks.base_hook.BaseHook.get_hook方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseHook.get_hook方法的具體用法?Python BaseHook.get_hook怎麽用?Python BaseHook.get_hook使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在airflow.hooks.base_hook.BaseHook的用法示例。


在下文中一共展示了BaseHook.get_hook方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: from airflow.hooks.base_hook import BaseHook [as 別名]
# 或者: from airflow.hooks.base_hook.BaseHook import get_hook [as 別名]
    def execute(self, context):
        source_hook = BaseHook.get_hook(self.source_conn_id)

        self.log.info("Extracting data from %s", self.source_conn_id)
        self.log.info("Executing: \n %s", self.sql)
        results = source_hook.get_records(self.sql)

        destination_hook = BaseHook.get_hook(self.destination_conn_id)
        if self.preoperator:
            self.log.info("Running preoperator")
            self.log.info(self.preoperator)
            destination_hook.run(self.preoperator)

        self.log.info("Inserting rows into %s", self.destination_conn_id)
        destination_hook.insert_rows(table=self.destination_table, rows=results)
開發者ID:sstm2,項目名稱:incubator-airflow,代碼行數:17,代碼來源:generic_transfer.py

示例2: execute

# 需要導入模塊: from airflow.hooks.base_hook import BaseHook [as 別名]
# 或者: from airflow.hooks.base_hook.BaseHook import get_hook [as 別名]
    def execute(self, context):
        source_hook = BaseHook.get_hook(self.source_conn_id)

        logging.info("Extracting data from {}".format(self.source_conn_id))
        logging.info("Executing: \n" + self.sql)
        results = source_hook.get_records(self.sql)

        destination_hook = BaseHook.get_hook(self.destination_conn_id)
        if self.preoperator:
            logging.info("Running preoperator")
            logging.info(self.preoperator)
            destination_hook.run(self.preoperator)

        logging.info("Inserting rows into {}".format(self.destination_conn_id))
        destination_hook.insert_rows(table=self.destination_table, rows=results)
開發者ID:16522855,項目名稱:airflow,代碼行數:17,代碼來源:generic_transfer.py

示例3: execute

# 需要導入模塊: from airflow.hooks.base_hook import BaseHook [as 別名]
# 或者: from airflow.hooks.base_hook.BaseHook import get_hook [as 別名]
    def execute(self, context):
        source_hook = BaseHook.get_hook(self.source_conn_id)

        logging.info("Extracting data from {}".format(self.source_conn_id))
        logging.info("Executing: \n" + self.sql)
        results = source_hook.get_records(self.sql)

        destination_hook = TeradataHook(teradata_conn_id=self.destination_conn_id)
        if self.preoperator:
            logging.info("Running preoperator")
            logging.info(self.preoperator)
            destination_hook.run(self.preoperator)

        if self.batch:
            logging.info("Inserting {} rows into {} with a batch size of {} rows".format(len(results), self.destination_conn_id, self.batch_size))
            destination_hook.bulk_insert_rows(table=self.destination_table, rows=iter(results), commit_every=self.batch_size,  unicode_source=self.unicode_source)
        else:
            logging.info("Inserting {} rows into {}".format(len(results), self.destination_conn_id))
            destination_hook.insert_rows(table=self.destination_table, rows=iter(results), commit_every=1000, unicode_source=self.unicode_source )
開發者ID:flolas,項目名稱:docker-airflow,代碼行數:21,代碼來源:transfertoteradata_operator.py

示例4: get_db_hook

# 需要導入模塊: from airflow.hooks.base_hook import BaseHook [as 別名]
# 或者: from airflow.hooks.base_hook.BaseHook import get_hook [as 別名]
 def get_db_hook(self):
     return BaseHook.get_hook(conn_id=self.conn_id)
開發者ID:apache,項目名稱:incubator-airflow,代碼行數:4,代碼來源:check_operator.py


注:本文中的airflow.hooks.base_hook.BaseHook.get_hook方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。