我有一个简单的impyla代码,我想从我的光标创建一个pandas dataFrame。我的代码正在运行,但我的dataframe始终是一个空dataframe。如果我直接在impala上运行查询,结果不是空的。我的代码是这样的:
from impala.dbapi import connect
from impala.util import as_pandas
conn = connect(host='impala_server', port=21051,
user='user' , password='pass',
use_ssl=True,
auth_mechanism='PLAIN')
cursor = conn.cursor()
cursor.execute("SELECT * FROM TABLE")
results = cursor.fetchall()
df = as_pandas(cursor)
print(df.head()) 请帮帮我,我做错了什么?
发布于 2018-11-19 20:21:35
只需删除:
results = cursor.fetchall()从你的代码中。应该能行得通。
发布于 2020-07-21 16:40:06
'results = cursor.fetchall() ' delete this line and it will be ok.
from impala.dbapi import connect
from impala.util import as_pandas
conn = connect(host='****.com', port=****, database='****')
cursor = conn.cursor()
cursor.execute('select * from table limit 10')
df = as_pandas(cursor)
df.head()我运行上面的代码,它运行得很好。
https://stackoverflow.com/questions/50797503
复制相似问题