引发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
有人能帮我纠正这个错误吗