[英]Execute multiple queries in single pyhive.execute command
Using pyhive, is it possible to execute multiple hql's like 'CREATE TABLE TABLE1 (ITEM_KEY BIGINT );CREATE TABLE TABLE2 (ITEM_NAME BIGINT );'. 使用pyhive,是否可以执行多个hql,如'CREATE TABLE TABLE1(ITEM_KEY BIGINT); CREATE TABLE TABLE2(ITEM_NAME BIGINT);'。
Sample code 示例代码
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)
How about you split your query and execute them one by one? 如何拆分查询并逐个执行?
qList = query.split(";")
for q in qList:
cursor.execute(q)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.