在单个 pyhive.execute 命令中执行多个查询

使用pyhive,是否可以执行多个hql,例如'CREATE TABLE TABLE1 (ITEM_KEY BIGINT);CREATE TABLE TABLE2 (ITEM_NAME BIGINT);'。


示例代码


from pyhive import hive

conn = hive.Connection(host=host

                       , port=port, username=user

                       , password=passwd

                       , auth=auth)

cursor = conn.cursor()

query= 'CREATE TABLE TABLE1 (ITEM_KEY BIGINT );CREATE TABLE TABLE2 (ITEM_NAME BIGINT );'. 

cursor.execute(query)


郎朗坤
浏览 263回答 1
1回答

哆啦的时光机

您如何拆分查询并一一执行它们?qList = query.split(";")for q in qList:    cursor.execute(q)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python