Assuming I have a data table structured as tb_user(id int primary key, name varchar(15), age int, score float).
The insert_sql = 'insert into tb_user values(%s, %s, %s, %s)'.
If the command c.execute(insert_sql, [1, 'John', '', '85.0']) is executed, an exception will be raised saying "Incorrect integer value: '' for column 'age' at row 1".
If the command c.execute(insert_sql, [1, 'John', '23', '']) is executed, an exception will be raised saying "Data truncated for column 'score' at row 1".
My question is, when inserting empty string ('') for column of float/int type, how to keep the inserted value NULL (e.g. age = NULL, or score = NULL), instead of raising an exception?
Thanks for your help!
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/mysql-python/discussion/70461/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/