in python 2.7.3, wins 10, mysql remote server 5.6.23, mysql.connector 2.1.3,
if wanna run these 2 queries in python mysql.connector:
select * limit 5; select distinct colum_a b;
i got following error message using code below:
error -1: no result set fetch from.
here code:
import mysql.connector mysql cursor = conn.cursor () sql1 = "select * limit 5;select distinct colum_a b" cursor.execute(sql1,multi=true) row = cursor.fetchall () warning = cursor.fetchwarnings() print row print warning cursor.close () conn.close ()
here mysql cursor.execute() official document, confuses me. guru enlighten? thanks!
https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html
change code to-
iterable = cursor.execute(sql1,multi=true) item in iterable: print(item.fetchall())
should work.