简体   繁体   中英

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 );'.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM