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

Execute multiple queries in single pyhive.execute command

使用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)

你如何拆分你的查询并一个一个地执行它们?

qList = query.split(";")
for q in qList:
    cursor.execute(q)