我搜索了好几个论坛,找不到确切的答案。我正在连接到一个hivedb,用python运行查询,并将结果导出到一个.csv文件,但只能返回行,没有列标题。请参阅下面的示例代码。谢谢你的帮助!
import pyhs2
import csv
with pyhs2.connect(host='host',
port=10000,
authMechanism="PLAIN",
user='username',
password='password',
database='default') as conn:
with conn.cursor() as cur:
cur.execute("select * from table limit 100")
result = cur.fetchall()
c = csv.writer(open("temp.csv", "wb"))
for row in result:
c.writerow(row)
暂无答案!
目前还没有任何答案,快来回答吧!