from pyhive import presto
import pandas as pd
import numpy as np
import os
import time
#连接presto
conn = presto.connect(protocol = 'https', host = 'host.com', port = 8443, username = 'username', password = 'password')
cursor = conn.cursor()
#数据读取
wd = 'C:/Users/desktop' #改变默认路径,可以省略此步骤直接读取绝对路径
os.chdir(wd)
file_name = pd.read_csv("file.csv",header = None)
#建表
sql = '''
create table table_name
(
id bigint,
uid bigint,
order_id bigint,
aa varchar(125),
bb bigint
)
WITH (format = 'ORC')'''
cursor.execute(sql)
cursor.fetchall()
#插入数据
sql = 'insert into table_name'
for i in range(file_name.iloc[:,0].size):
sql = sql + str(tuple(file_name.iloc[i])) + ','
sql = sql[:-1]
start = time.perf_counter()
cursor.execute(sql)
cursor.fetchall()
conn.commit()
end = time.perf_counter()
print('use time is %6.3f' % (end-start))
https://blog.csdn.net/longshenlmj/article/details/51702343?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164420627516780255281795%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=164420627516780255281795&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-1-51702343.pc_search_insert_ulrmf&utm_term=with+%28format+%3D+orc%29&spm=1018.2226.3001.4187