Tags
python
Asked 2 years ago
13 Aug 2021
Views 10033
Esteban

Esteban posted

Python - mysql.connector.errors.InternalError: Unread result found

i am making code in MySQ by Python where finding date wise record L if exists or not .

for ind in df.index:
		sel="select * from  data where `date`='{0}'".format(df['date'][ind])
		cursor2.execute(sel)
		data=cursor2.fetchone()
		if len(data)==0 :
			print("list")
		else :
			print("Already exists")


give me following error :

Traceback (most recent call last):
  File "mysqllist.py", line 22, in <module>
    cursor2.execute(sel)
 
    self._connection.handle_unread_result()
  
    raise errors.InternalError("Unread result found")
mysql.connector.errors.InternalError: Unread result found



ruby-rails

ruby-rails
answered Aug 13 '21 00:00


cursor2= db.cursor(buffered=True)

when creating cursor, pass parameter buffered= True.
buffered= True says that it should read result every time fresh otherwise with fetchone() method , it will not read same data over and over again
jqueryLearner

jqueryLearner
answered Jun 25 '22 00:00


import mysql.connector
db= mysql.connector.connect()
crs= db.cursor(buffered=True)


buffered= True can do the job.
Post Answer