So I have run into a problem which I can't seem to find a solution for. I've
tried debugging but when I get into the c code I start to get a little lost.
It seems I can't insert decimal values with the MySQL-python client. Doing it
from the mysql command line client works fine but not from python.
I've tried using integer, float, Decimal, and string types and they all yield
the same error. Has anyone else seen this before?
mysql>desctest_table;+------------+------------------+------+-----+---------+----------------+|Field|Type|Null|Key|Default|Extra|+------------+------------------+------+-----+---------+----------------+|id|int(10)unsigned|NO|PRI|NULL|auto_increment||coeficient|decimal(10,10)|NO||NULL||+------------+------------------+------+-----+---------+----------------+importMySQLdbconn=MySQLdb.connect(...)cursor=conn.cursor()cursor.execute("INSERT INTO `test_table` (`coeficient`) VALUES(%s)",('10.0'))cursor.close()conn.close()
Gives me:
"Warning: Out of range value for column 'coeficient' at row 1"
Python 2.7.1
Mysql client 5.1.53_0
Percona server 5.1.53-rel12.4-log
MySQL-python 1.2.3
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So I have run into a problem which I can't seem to find a solution for. I've
tried debugging but when I get into the c code I start to get a little lost.
It seems I can't insert decimal values with the MySQL-python client. Doing it
from the mysql command line client works fine but not from python.
I've tried using integer, float, Decimal, and string types and they all yield
the same error. Has anyone else seen this before?
Gives me:
"Warning: Out of range value for column 'coeficient' at row 1"
Python 2.7.1
Mysql client 5.1.53_0
Percona server 5.1.53-rel12.4-log
MySQL-python 1.2.3
Your schema is wrong.
http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-
changes.html
M is the maximum number of digits (the precision). It has a range of 1 to 65.
(Older versions of MySQL permitted a range of 1 to 254.)
D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.
10.0 can't fit in DECIMAL(10,10); only values <1.
Thanks, I read that page at least 3 times and still missed the point. Le sigh.