pyhon3+jaydebeapi3访问phoenix

import jaydebeapi
import pandas as pd
import pandas.io.sql as psql

driver = 'org.apache.phoenix.jdbc.PhoenixDriver'
url = 'jdbc:phoenix:node1:2181:default'
arFile = r'/opt/cloudera/parcels/PHOENIX/lib/phoenix/phoenix-5.0.0-cdh6.2.0-client.jar'

conn = jaydebeapi.connect(driver, [url, '',''], jarFile)
curs = conn.cursor()
curs.execute('select * from users')
rows = curs.fetchall()
print(rows[0])

query = "select * from users"
df = psql.read_sql_query(query, conn) #pd.read_sql_query(sqlalchemy.text(sql), con=conn)
print(df)

curs.close()
conn.close()
posted @ 2020-03-03 21:04  舟山渔夫  阅读(578)  评论(0编辑  收藏  举报