问题:使用select进行查表,出现连接事务一直连接,导致锁表,没办法对表格进行修改操作。单独执行该操作,发现sql查询响应时间为10ms。
解决办法:
在建立conn连接时,设置commit如下:
dbconn = MySQLdb.connect(host=sql_conf.MYSQL_HOST, port=sql_conf.MYSQL_PORT, user=sql_conf.MYSQL_USER, passwd=sql_conf.MYSQL_PASS, db=sql_conf.MYSQL_DB, connect_timeout=10)
dbconn.autocommit(True)
默认情况下,autocommit处于关闭状态,需要手动开启。