[Tutor] MySQLdb: dropping zeroes!

Tim Johnson tim at johnsons-web.com
Tue Apr 6 22:04:28 EDT 2004


Hello All:
    I'm using MySQLdb to read and write from a database where
I have values stored as a decimal(10,2) datatype.
To illustrate:
  The following value which is stored as 
    0.94
  is read back by MySQLdb with the DictCursor option as 
    0.94
  so far so good!
  But, alas! A value stored as 
    1.00
  is read back by MySQLdb with the DictCursor option as 
    1.0
 
 That is not good! My type-checking will flag that value as invalid
 because a precision of 2 places to the right of the decimal point
 is expected.

 I can handle this with my own code, but perhaps someone can tell
 me if the MySQLdb api can take care of this with some internal
 setting. 

 TIA
 tim
-- 
Tim Johnson <tim at johnsons-web.com>
      http://www.alaska-internet-solutions.com



More information about the Tutor mailing list