mysql连接
conn_game = MySQLdb.connect(host=app.config["DATABASE_IP"], user=app.config["DATABASE_USER"],
passwd=app.config["DATABASE_PWD"], db=app.config["DATABASE_LOGIN_DB"])
全部查询
cursor = conn_game.cursor()
cursor.execute('select id, pid, value from `tb` where id=%s', (uid,))
prop = cursor.fetchall()
单个查询
cursor = conn_game.cursor()
cursor.execute('select id, pid, value from `tb` where id=%s', (uid,))
row = cursor.fetchone()
更新数据
cursor = conn_login.cursor()
sql = "update `tb1` set device=CONCAT(device,'DEL') where id in (select id from `tb2` where uid in (%s));"
cursor.execute(sql, (uid,))
conn_login.commit()
cursor.close()
网友评论