Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
引发errorclass,errorvalue\u mysql\u异常。编程错误:在Python2.7中光标关闭_Python_Mysql_Exception_Cursor - Fatal编程技术网

引发errorclass,errorvalue\u mysql\u异常。编程错误:在Python2.7中光标关闭

引发errorclass,errorvalue\u mysql\u异常。编程错误:在Python2.7中光标关闭,python,mysql,exception,cursor,Python,Mysql,Exception,Cursor,我在run.py from emotion_classification_model import learningbased import threading def run_code(): threading.Timer(60.0, run_code).start() learningbased() run_code() 还有另一个insert.py文件,其中包含 import MySQLdb conn = MySQLdb.connect(host="loca

我在
run.py

from emotion_classification_model import learningbased
import threading

 def run_code():

    threading.Timer(60.0, run_code).start()
    learningbased()

 run_code()
还有另一个
insert.py
文件,其中包含

import MySQLdb

conn =  MySQLdb.connect(host="localhost",user="root",passwd="",db="chat_app",use_unicode=True,charset="utf8")
x = conn.cursor()

def insert_result(insert_emotion):

   x.execute('''INSERT into machinelearningresults (Emotion) values (%s)''', (insert_emotion))
  conn.commit()
  x.close()

def r_insert(rule_result):
  x.execute('''INSERT into rulebasedresults (Emotion) values (%s)''', (rule_result))
  conn.commit()
  x.close()
  conn.close()
当我调用
learningbase()
函数中的
insert\u result(insert\u emotion)
r\u insert(rule\u result)
函数时,它会产生以下错误

raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: cursor closed
有人能帮我纠正这个错误吗