conn = create_engine('mysql+pymysql:user:passwd@host:port/db?charset=etf-8')
try:
dataIn2File.to_sql(table_name,con=conn,if_exists='append',index=False)
except Exception as ee:
logger.error('fileToMysql fialed',ee)
traceback.print_exc()
finally:
conn.dispose() //关闭连接
sqlalchemy连接和关闭数据库
最新推荐文章于 2024-06-17 17:12:17 发布