有人用过pymysql么?遇到个问题


这种方式可以取出mysql的数据:
self.cursor.execute('call uuidproc(@uuid)')
self.cursor.execute('select @uuid')
r = self.cursor.fetchall()
uuid = r[0][0]

但是这样却不能:
self.cursor.execute('call uuidproc(@uuid);select @uuid;')
r = self.cursor.fetchall()
uuid = r[0][0]

请高人帮忙解答一下。

pymysql python mysqldb mysql

feveren 11 years, 3 months ago

因为self.cursor.execute的时候,已经将结果集赋值给了self的一些属性,在赋值的时候执行了检测,self.cursor.execute('call uuidproc(@uuid);select @uuid;')这样做相当于只执行了
call uuidproc(@uuid)

zetsubo answered 11 years, 3 months ago

Your Answer