我有一张桌子。这是创建语句。
CREATE TABLE `runsettings` (
`runnumber` mediumint(9) NOT NULL,
`equipment` varchar(45) NOT NULL,
`wafer` varchar(45) NOT NULL,
`settingname` varchar(100) NOT NULL,
`float8value` double DEFAULT NULL,
`apcrunid` varchar(45) DEFAULT NULL,
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`intvalue` int(11) DEFAULT NULL,
`floatvalue` float DEFAULT NULL,
`Batch` varchar(45) DEFAULT NULL,
`IndexNum` smallint(6) DEFAULT '1',
`stringvalue` mediumtext,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1056989 DEFAULT CHARSET=latin1;
这是我的插入语句:
import mysql.connector
cnx = mysql.connector.connect(user='test',
password ='test',host='0.0.0.1',
database='test')
vallist = [(471285, u'CT19', 7, u'271042', u'Etch Time Min', None, None, None),
(471285, u'CT19', 7, u'00000', u'Etch Time Min', None, None, 'None')]
cursor = cnx.cursor()
# ss =
cursor.executemany("INSERT INTO runsettings (apcrunid,equipment,runnumber,wafer,settingname,intvalue,floatvalue,float8value) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)",vallist)
cnx.commit()
所以我尝试插入这些值。
vallist = [471285, u'CT19', 7, u'271042', u'Etch Time Min', None, None, None,
471285, u'CT19', 7, u'00000', u'Etch Time Min', None, None, 'None']
This is getting inserted.
Result on DB
But when the list value is this one (difference is the string 'None'
gets evaluated first):
vallist = [471285, u'CT19', 7, u'271042', u'Etch Time Min', None, None, 'None',
471285, u'CT19', 7, u'271042', u'Etch Time Min', None, None, None]
它给出了截断的错误。
Data truncated for column 'float8value' at row 2
为什么当包含的行None
是列表中的第一个,它不会在第一个列表上给出相同的截断错误吗?