本文整理汇总了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)
示例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)
示例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 )
示例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)