当前位置: 首页>>代码示例>>Python>>正文


Python MySqlHook.bulk_dump方法代码示例

本文整理汇总了Python中airflow.hooks.mysql_hook.MySqlHook.bulk_dump方法的典型用法代码示例。如果您正苦于以下问题:Python MySqlHook.bulk_dump方法的具体用法?Python MySqlHook.bulk_dump怎么用?Python MySqlHook.bulk_dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.hooks.mysql_hook.MySqlHook的用法示例。


在下文中一共展示了MySqlHook.bulk_dump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_mysql_hook_test_bulk_dump

# 需要导入模块: from airflow.hooks.mysql_hook import MySqlHook [as 别名]
# 或者: from airflow.hooks.mysql_hook.MySqlHook import bulk_dump [as 别名]
 def test_mysql_hook_test_bulk_dump(self):
     from airflow.hooks.mysql_hook import MySqlHook
     hook = MySqlHook('airflow_ci')
     priv = hook.get_first("SELECT @@global.secure_file_priv")
     if priv and priv[0]:
         # Confirm that no error occurs
         hook.bulk_dump("INFORMATION_SCHEMA.TABLES", os.path.join(priv[0], "TABLES"))
     else:
         self.skipTest("Skip test_mysql_hook_test_bulk_load "
                       "since file output is not permitted")
开发者ID:matthiashuschle,项目名称:airflow,代码行数:12,代码来源:operators.py

示例2: test_mysql_hook_test_bulk_dump_mock

# 需要导入模块: from airflow.hooks.mysql_hook import MySqlHook [as 别名]
# 或者: from airflow.hooks.mysql_hook.MySqlHook import bulk_dump [as 别名]
    def test_mysql_hook_test_bulk_dump_mock(self, mock_get_conn):
        mock_execute = mock.MagicMock()
        mock_get_conn.return_value.cursor.return_value.execute = mock_execute

        from airflow.hooks.mysql_hook import MySqlHook
        hook = MySqlHook('airflow_ci')
        table = "INFORMATION_SCHEMA.TABLES"
        tmp_file = "/path/to/output/file"
        hook.bulk_dump(table, tmp_file)

        from airflow.utils.tests import assertEqualIgnoreMultipleSpaces
        mock_execute.assert_called_once()
        query = """
            SELECT * INTO OUTFILE '{tmp_file}'
            FROM {table}
        """.format(tmp_file=tmp_file, table=table)
        assertEqualIgnoreMultipleSpaces(self, mock_execute.call_args[0][0], query)
开发者ID:matthiashuschle,项目名称:airflow,代码行数:19,代码来源:operators.py


注:本文中的airflow.hooks.mysql_hook.MySqlHook.bulk_dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。