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


Python PrestoClient.execute_query方法代码示例

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


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

示例1: test_connection_failed

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
    def test_connection_failed(self, mock_conn, mock_port):
        mock_port.return_value = 8080
        client = PrestoClient('any_host', 'any_user')
        client.execute_query("any_sql")

        self.assertTrue(mock_conn().close.called)
        self.assertFalse(client.execute_query("any_sql"))
开发者ID:Teradata,项目名称:presto-admin,代码行数:9,代码来源:test_prestoclient.py

示例2: test_http_call_failed

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
    def test_http_call_failed(self, mock_conn):
        client = PrestoClient('any_host', 'any_user', 8080)
        mock_conn.side_effect = HTTPException("Error")
        self.assertFalse(client.execute_query("any_sql"))

        mock_conn.side_effect = socket.error("Error")
        self.assertFalse(client.execute_query("any_sql"))
开发者ID:amrutagokhale,项目名称:presto-admin,代码行数:9,代码来源:test_prestoclient.py

示例3: test_default_request_called

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
    def test_default_request_called(self, mock_conn):
        client = PrestoClient('any_host', 'any_user', 8080)
        headers = {"X-Presto-Catalog": "hive", "X-Presto-Schema": "default",
                   "X-Presto-User": 'any_user'}

        client.execute_query("any_sql")
        mock_conn.assert_called_with('any_host', 8080, False, URL_TIMEOUT_MS)
        mock_conn().request.assert_called_with("POST", "/v1/statement",
                                               "any_sql", headers)
        self.assertTrue(mock_conn().getresponse.called)
开发者ID:amrutagokhale,项目名称:presto-admin,代码行数:12,代码来源:test_prestoclient.py

示例4: test_execute_query_get_port

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
 def test_execute_query_get_port(self, run_mock, conn_mock):
     client = PrestoClient('any_host', 'any_user')
     client.rows = ['hello']
     client.next_uri = 'hello'
     client.response_from_server = {'hello': 'hello'}
     run_mock.return_value = _AttributeString('http-server.http.port=8080')
     run_mock.return_value.failed = False
     client.execute_query('select * from nation')
     self.assertEqual(client.port, 8080)
     self.assertEqual(client.rows, [])
     self.assertEqual(client.next_uri, '')
     self.assertEqual(client.response_from_server, {})
开发者ID:amrutagokhale,项目名称:presto-admin,代码行数:14,代码来源:test_prestoclient.py

示例5: test_http_answer_valid

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
 def test_http_answer_valid(self, mock_response, mock_request, mock_port):
     mock_port.return_value = 8080
     client = PrestoClient('any_host', 'any_user')
     mock_response.return_value.read.return_value = '{}'
     type(mock_response.return_value).status = \
         PropertyMock(return_value=200)
     self.assertTrue(client.execute_query('any_sql'))
开发者ID:Teradata,项目名称:presto-admin,代码行数:9,代码来源:test_prestoclient.py

示例6: test_connection_failed

# 需要导入模块: from prestoadmin.prestoclient import PrestoClient [as 别名]
# 或者: from prestoadmin.prestoclient.PrestoClient import execute_query [as 别名]
    def test_connection_failed(self, mock_conn):
        client = PrestoClient('any_host', 'any_user', 8080)
        client.execute_query("any_sql")

        self.assertTrue(mock_conn().close.called)
        self.assertFalse(client.execute_query("any_sql"))
开发者ID:amrutagokhale,项目名称:presto-admin,代码行数:8,代码来源:test_prestoclient.py


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