使用 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)
关于python - 在单个 pyhive.execute 命令中执行多个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52160361/