Qihoo360 / Atlas

A high-performance and stable proxy for MySQL, it is developed by Qihoo's DBA and infrastructure team
GNU General Public License v2.0
4.65k stars 1.15k forks source link

python脚本查询读写分离问题 #204

Closed sunhackboy closed 4 years ago

sunhackboy commented 4 years ago

使用python脚本查询atlas数据,一直在maser节点查询,脚本如下,使用shell脚本/php脚本可以正常读写分离 `import pymysql import time

def select(): db=pymysql.connect(host='x.x.x.x',user="xx",password="xxx",db="test",port=2040) cursor=db.cursor() result=cursor.execute("select * from user;") cursor.close() ` 麻烦大佬看下啥问题

sunhackboy commented 4 years ago

已经找到问题,pymysql模块默认autocommit为false,在connect()函数添autocommit=True即可