During my work when using python and MySQL, I've faced to
problem with updating DECIMAL fields. When I am executing a query
cursor.execute("UPDATE t SET v = v + %s", Decimal('0.30'))
on a table like that:
CREATE TABLE t (
v decimal(9,2) NOT NULL,
) ENGINE=MyISAM ;
INSERT INTO t VALUES (0.00);
sporadically I get "Warning: Data truncated for column 'v' at
row 1". I've analyzed MySQLdb a little, and found out that executed
query is "UPDATE t SET v = v + '0.30'". I think, because of these
single quotemarks, MySQL truncate something during computation of
Is this MySQL bug or do we need for MySQLdb patch to add Decimal
type conversion to string without quotes?
Sounds more like your 't' values have exceeded 9999999.99. Is that possible?
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.