验证中...
csv-mysql
Raw Copy
# -*- coding:utf-8 -*-
'''
note:
'''
import numpy as np
import pandas as pd
import math
import os
from sqlalchemy import create_engine
os.chdir('E:\\pyworkspace\\gj11-multi-ai\\position')#用于改变当前工作目录到指定的路径。
dir_list=os.listdir('E:\\pyworkspace\\gj11-multi-ai\\position')#返回指定路径下的文件和文件夹列表
engine = create_engine('mysql+pymysql://root:root@127.0.0.1:3306/gj') # 建立mysql引擎
for i in dir_list:
df=pd.DataFrame(pd.read_csv(i, encoding='utf-8'))
df.to_sql("trace", engine, if_exists='append',index=False) # 将csv数据导入到table1表中, 数据类型pandas会自动识别
#temp.append(frame)
print("end")
#df=pd.concat(temp,ignore_index=True)

Comment list( 0 )

You need to Sign in for post a comment

Help Search