Python奇怪的pymysql错误。无法弄清楚

时间:2017-01-09 00:07:00

标签: python mysql

我一直收到这个sql错误。我似乎无法诊断出这个问题。任何帮助都会很棒。

据我所知,问题点是mySQL字段的第二次更新。如果我没有弄错的话,当我只有第一个时,我没有得到错误。是连接提交/关闭的东西?这个错误看起来很奇怪。

这是故障代码:

for item in to_render:
    def sequence_and_encode():
        print("RENDERING SEQUENCES.")
        with conn.cursor() as c:
            sql = "UPDATE test_database.encode_queue SET status=%s WHERE UID=%s"
            c.execute(sql, ('rendering', uid, ))
            conn.commit()
            conn.close()
        map_results = pool.map_async(subprocess.check_output, sequence_all).get(9999999)
        pool.close()
        pool.join()
        anim_name = str(uid)        
        encode_type = (
            "encode_templates/prores_hq.sh " + "'" + anim_name + "' '" + sequence_creation_temp + "' '" + videos_final + "' '" + scripts_final + "'")
        output = subprocess.check_output(encode_type, shell=True)
        with conn.cursor() as c:
            sql = "UPDATE test_database.encode_queue SET status=%s WHERE UID=%s"
            c.execute(sql, ('complete', uid, ))
            conn.commit()
            conn.close()
        gc.collect()
    sequence_and_encode()  

这是错误:

Traceback (most recent call last):
 File "/Users/marcleonard/PycharmProjects/Creating Animation/pickup_encodes.py", line 116, in <module>
    sequence_and_encode()                      #comment out to disable render #THIS WAS NOT INDENTED (to this point....)
  File "/Users/marcleonard/PycharmProjects/Creating Animation/pickup_encodes.py", line 112, in sequence_and_encode
    c.execute(sql, ('complete', uid, ))
  File "/Users/marcleonard/anaconda/lib/python3.5/site-packages/pymysql/cursors.py", line 166, in execute
    result = self._query(query)
  File "/Users/marcleonard/anaconda/lib/python3.5/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/Users/marcleonard/anaconda/lib/python3.5/site-packages/pymysql/connections.py", line 834, in query
    self._execute_command(COMMAND.COM_QUERY, sql)
  File "/Users/marcleonard/anaconda/lib/python3.5/site-packages/pymysql/connections.py", line 1033, in _execute_command
    raise err.InterfaceError("(0, '')")
pymysql.err.InterfaceError: (0, '')

0 个答案:

没有答案