Decimal type

Help
2010-01-30
2012-09-19
  • Alexey Smolsky

    Alexey Smolsky - 2010-01-30

    During my work when using python and MySQL, I've faced to

    problem with updating DECIMAL fields. When I am executing a query

    like that:


    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

    expression.

    Is this MySQL bug or do we need for MySQLdb patch to add Decimal

    type conversion to string without quotes?

     
  • Jack Repenning

    Jack Repenning - 2010-07-30

    Sounds more like your 't' values have exceeded 9999999.99. Is that possible?

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks