如何从python向MYSQL中插入空小数/日期时间?
我有数据文件:
《劳拉》、《劳拉·埃伦堡》、《5342咸鱼巷》、《纳什维尔》、《TN》、《38010》、《2000-02-22》、《454-56-768》
请注意结尾处的""。
我使用的是Python代码:
选择 | 换行 | 行号
- data = []
- infile = open ("./BIGPVFC-ASC10e/Employee.asc", "r")
- for line in infile:
- line = line.rstrip("\n")
- line = line.strip()
- seq = line.split(", ")
- for i in range(0,9):
- seq[i] = seq[i].strip("'")
- seq = tuple (seq)
- data.append(seq)
- infile.close()
- cursor.executemany ("""insert into PV_employee
- (employeeid, employeename, employeeaddress, employeecity, employeestate, employeezip, employeedatehired, employeebirthdate, employeesupervisor)
- values (%s, %s, %s, %s, %s, %s, %s, %s, %s)""", data)
我的桌子是:
创建表PV_Employee
(ployeeid varchar(10)不为空
,ployeename varchar(25)空
,ployeeAddress varchar(30)空
,Emploecity varchar(20)空
,雇员地产字符(2)为空
,ployeeZip varchar(10)空
,EmploeDate雇用日期时间为空
,ployeeBirthDate DateTime空
,ployeesSupervisor varchar(10)为空
,主键(EmploeID)
);
在其中我收到错误消息"WARNING:Out Out Range Value for Column....."
在小数为空的情况下,我得到"警告:不正确的小数值:''for Column..."
我已尝试将''更改为''、'NULL'和NULL。这些措施似乎都没有奏效。有什么建议吗?