ngine = create_engine(‘mysql://‘+etc.mysql_user+‘:‘+etc.mysql_passwd+‘@‘+etc.mysql_host+‘:‘+str(etc.mysql_port)+‘/‘+etc.host_name+‘?charset=utf8‘,encoding="utf-8",pool_size=100, pool_recycle=3600, echo=False)
pool_recycle设置为3600(该值必须小于数据库服务器的interactive_timeout),连接池中的空闲连接超过1小时候,自动释放。
原文:http://www.cnblogs.com/sshch/p/6805639.html