该代码昨天运行良好,作为 cron 作业运行。今天突然,它不是,我收到这个错误:
Traceback (most recent call last):
File "C:/Users/ac33g1r1/Documents/BD_Scripts/test plist script.py", line 28, in <module>
[plist[sid], lastQ[0]] )
File "C:\Python33\pymysql\cursors.py", line 117, in execute
self.errorhandler(self, exc, value)
File "C:\Python33\pymysql\connections.py", line 187, in defaulterrorhandler
raise Error(errorclass, errorvalue)
pymysql.err.Error: (<class 'TypeError'>, TypeError("'int' does not support the buffer interface",))
我已经搜索过,无法弄清楚为什么这突然改变了。Windows Server 2008 上的 Python 版本是 3.3.0。我真的很想让这个 cron 工作再次工作,但不知道究竟是什么原因。
这是代码:
import pymysql
conn = pymysql.connect(host='1.2.3.4', port = 1234, user = 'uname', passwd='pword', db='db_x')
cur = conn.cursor()
lastQ = [165]
plist = [3327, 2145, 3429, 3442, 2905, 3339, 2628, 1655, 1831, 3202, 2551, 2110]
###Debug statements
print("plist")
print(len(plist))
print ("\n")
print("last[Q]")
print(lastQ[0] )
print ("\n")
lastQ[0] = lastQ[0] + 1
print(lastQ[0] )
# Code that is throwing error
for sid in range(len(plist)):
lastQ[0] = lastQ[0] + 1
cur.execute("""INSERT INTO queuelist(itemID, sortID)
VALUES(%s,%s)""",
[plist[sid], lastQ[0]] )
cur.close()
conn.close()