V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
wangyu8460958
V2EX  ›  Python

Python 队列脚本执行时报错 Warning: Truncated incorrect DOUBLE value: '[2627290]' r = r + self.execute(query, a)

  •  
  •   wangyu8460958 · 2017-05-05 18:23:54 +08:00 · 2330 次点击
    这是一个创建于 2752 天前的主题,其中的信息可能已经有所发展或是发生改变。

    当我使用如下脚本运行时:

    #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)

    请问下这个应该如何来解决?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1045 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 19ms · UTC 19:36 · PVG 03:36 · LAX 11:36 · JFK 14:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.