再次创建游标连接会显示错误

时间:2018-03-28 07:50:57

标签: python mysql cursor connection

我有一个py程序,如下所示:

    sess_id = 1;
    print(sess_id)
    cursor_one = conn.cursor()
    cursor_one.execute("select time_arr from info where sess_id= '%s'" % 
    (sess_id))
    data=cursor_one.fetchone()
    print(type(data))
    print(data)
    print("datatwo conversions... start")
    cursor_two = conn.cursor()
    cursor_two.execute("select type from questions")
    data_two=cursor_two.fetchall()   

这是我的连词代码:

    conn= mysql.connector.connect
    (user="root",password="",host="localhost",database="videojs")

这里 cursor_one 在没有错误的情况下进行编译,但是当我在 cursor_two 中使用了相同的conn时,它会显示不应该发生的错误

Traceback (most recent call last):
  File 
"C:\xampp\htdocs\Ai_Edutech_trial_project 
\eclipse_workspace\Project\dbConn.py", line 117, in <module>
 read_from_db()
File 
"C:\xampp\htdocs\Ai_Edutech_trial_project 
\eclipse_workspace\Project\dbConn.py", line 23, in read_from_db
 cursor_two = conn.cursor()
  File "C:\Python34\lib\site-packages\mysql\connector\connection.py", line 
  829, in cursor
  self.handle_unread_result()
  File "C:\Python34\lib\site-packages\mysql\connector\connection.py", line 
 1093, in handle_unread_result
 raise errors.InternalError("Unread result found")
 mysql.connector.errors.InternalError: Unread result found

而且错误没有进入

 cursor_two.execute("select type from questions")

但在这一行

 cursor_two = conn.cursor()

我已经检查过,可能不是数据库错误,而是别的......请帮帮我

0 个答案:

没有答案