tonglin0325的个人主页

Presto学习笔记——Python客户端连接Presto

参考:三种客户端连接Presto

1.使用 presto-client

1
2
pip install presto-client==0.302.0

查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import presto

# demo about the usage of presto-python-client
conn = presto.dbapi.connect(
host='localhost',
port=8889,
user='hadoop',
catalog='xx_catalog',
schema='default'
)
cur = conn.cursor()
sql = "select * from xxx.xxx limit 10"
cur.execute(sql)
rows = cur.fetchall()
print(rows)