当前位置: 首页>>代码示例>>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;未经允许,请勿转载。