What is the cause of mysqldb's Warning: Truncated incorrect DOUBLE value error?

Viewed 28964

I am getting many warnings of the same kind --

Warning: Truncated incorrect DOUBLE value: '512121500B'

-- but cannot figure out why.

The MySQL table dr_snapshot looks like this:

PremiseID char(10) Primary Key
cycle SMALLINT(6)
last_read DATETIME
reading INTEGER
DeviceID INTEGER

I want to delete many rows by PremiseID. Here is one in particular: '512121500B'.

Here is my Python function that deletes by PremiseID:

def delDrSnapRow(premiseID, db):
    sql_cmd = " ".join([
        "delete ",
        "from dr_snapshot ",
        "where PremiseID = " + str(premiseID) + " ; "])

    del_cur = db.cursor()
    rc = del_cur.execute(sql_cmd)
    del_cur.close()

    return rc

PremiseID is a string, not a double. What am I missing here?

Many thanks.

Edit

After modifying my delete procedure to use try: .. except, I am not seeing the warning. I believe I am not seeing the warning, because I'm not seeing the warning display -- print(e) -- in the except part.

I am left with the conclusion that the try: except somehow removed the error.

def delDrSnapRow(premiseID, db):
    sql_cmd = " ".join([
        "delete ",
        "from dr_snapshot ",
        "where PremiseID = " + "'" + premiseID + "' ; "])

    del_cur = db.cursor()

    try:
        rc = del_cur.execute(sql_cmd)

    except MySQLdb.Error, e:
        print "Error %d: %s" % (e.args[0], e.args[1])

    except MySQLdb.Warning, e:
        print(e)
        rc = del_cur.execute(sql_cmd)

    del_cur.close()

    return rc
3 Answers
Related