Leif160519的blog Leif160519的blog

——————

目录
python 多线程操作数据库
/  

python 多线程操作数据库

本文摘自:https://www.cnblogs.com/pxfb/p/6923797.html
如果使用多线程操作数据库,容易引起多用户操作锁表

OperationalError: (2013, 'Lost connection to MySQL server during query')

使用多线程时,出现链接服务器消失的错误,在链接数据库时,加入ping(True)方法

conn=MySQLdb.connect('192.168.1.2','root','root','ant',charset='utf8')
cur = conn.cursor()
conn.ping(True)

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题python 多线程操作数据库
作  者Leif160519
出  处https://github.icu/articles/2019/10/08/1570523797255.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!