python - 如何使用 python 加载 Hive 表?
问题描述
我想在 python 中加载我的配置单元表。
我已经尝试使用 pyhive 加载,但它给出了 SASL 代理错误。为此要安装哪些软件包?
解决方案
您将需要安装:-
pip install sasl
pip install thrift-sasl
pip install thrift
pip install PyHive
现在您必须连接到Hive:
from pyhive import hive
conn = hive.Connection(host="URL", port=PORT_NUMBER, username="NAME", password="YOUR_PASSWORD")
建立 hive 连接后,您可以立即运行查询:
cursor = conn.cursor()
cursor.execute("SELECT * FROM table")
print(cur.fetchone())
注意:您可以使用连接 (conn) 在 pandas 中创建数据框:
import pandas as pd
df = pd.read_sql("SELECT * FROM table", conn)
推荐阅读
- angular - 在全日历角度中使用 rrule 隔夜双周重复事件
- java - 如何创建实现 3 个接口的此类的 Array?
- sortablejs - 知道哪个 div 是 Sortable.js 的目标
- angular - 尝试向 API(Angular、TypeScript、RxJS)发出多个请求时出现 TypeScript 可观察到的错误
- python - 用零填充 pandas 数据帧上的行,直到 N 计数
- mysql - mysql中解码Base64列显示BLOB
- rust - Near-bindgen 宏:不支持的参数类型
- javascript - 无法使用cdn加载axios
- python - 如何从 Python 列表和 str 生成唯一名称
- python-3.x - 如何使用 GUI 和 netmiko 正确使用函数