当前位置: 首页 > 后端技术 > Python

如何使用Python连接hive

时间:2023-03-26 18:34:06 Python

安装依赖pipinstallsaslpipinstallthriftpipinstallthrift-saslpipinstallPyHivepython脚本示例frompyhiveimporthiveHOST="127.0.0.1"PORT=10000USERNAME=="hadoop."ConnectionASENAME="hadoop"DATAB(host=HOST,port=PORT,username=USERNAME,database=DATABASE)cursor=conn.cursor()#cursor.execute("INSERTINTOTABLEtest_out(name,count,time)SELECTname,count(1),to_date(time)FROMtestGROUPBYname,to_date(time)")cursor.execute("SELECT*FROMtest")forresultincursor.fetchall():打印(结果[2])

最新推荐
猜你喜欢