sqlalchemy连接和关闭数据库

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数据库连接

猜你喜欢

转载自blog.csdn.net/u011208984/article/details/108586203