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