当我使用如下脚本运行时:
#coding=utf-8
import MySQLdb
import numpy as np
conn = MySQLdb.connect(host='localhost',port = 3306,user='baidu',passwd='baidu',db='baidu')
cur = conn.cursor()
conn.autocommit(1)
query_sql = "select id from tmp.baiduVideo where created_at < date_sub(now(), interval 1 year);"
insert_sql = "insert ignore into tmp.baiduVideo_bak (select * from tmp.baiduVideo where id = %s);"
delete_sql = "delete from tmp.baiduVideo where id = %s;"
cur.execute(query_sql)
dataList = cur.fetchall()
aaa = np.array(dataList)
ids = []
for i in range(len(aaa)):
ids.append(aaa[i])
if (i+1)%100==0 :
cur.executemany(insert_sql,ids)
ids = []
cur.executemany(insert_sql,ids)
ids = []
for i in range(len(aaa)):
ids.append(aaa[i])
if (i+1)%100==0 :
cur.executemany(delete_sql,ids)
ids = []
cur.executemany(delete_sql,ids)
ids = []
cur.close
conn.close()
这个脚本的目的是把 tmp.baiduVideo 表的 1 年之前的数据归档到 tmp.baiduVideo_bak 表。 当我运行后出现如下错误提示: /usr/lib/python2.7/dist-packages/MySQLdb/cursors.py:206: Warning: Truncated incorrect DOUBLE value: '[2627290]' r = r + self.execute(query, a)
/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py:206: Warning: Truncated incorrect DOUBLE value: '[2627292]' r = r + self.execute(query, a)
/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py:206: Warning: Truncated incorrect DOUBLE value: '[2627295]' r = r + self.execute(query, a)
请问下这个应该如何来解决?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.