为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

郎朗坤 2021-06-06 12:50:00
使用pyhive,是否可以执行多个hql,例如'CREATE TABLE TABLE1 (ITEM_KEY BIGINT);CREATE TABLE TABLE2 (ITEM_NAME BIGINT);'。示例代码from pyhive import hiveconn = 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)
查看完整描述

1 回答

?
哆啦的时光机

TA贡献1779条经验 获得超6个赞

您如何拆分查询并一一执行它们?


qList = query.split(";")

for q in qList:

    cursor.execute(q)


查看完整回答
反对 回复 2021-06-09
  • 1 回答
  • 0 关注
  • 262 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号