1
我有數據文件:如何從Python中插入空小數/日期時間到MYSQL?
'Laura', 'Laura Ellenburg', '5342 Picklied Trout Lane', 'Nashville', '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)
我的表是:
create table PV_employee
(employeeid varchar(10) not null
,employeename varchar(25) null
,employeeaddress varchar(30) null
,employeecity varchar(20) null
,employeestate char(2) null
,employeezip varchar(10) null
,employeedatehired datetime null
,employeebirthdate datetime null
,employeesupervisor varchar(10) null
,primary key (employeeid)
);
在那裏我得到的錯誤「警告:超出範圍值的列..... 「
在空小數的情況下,我得到‘警告:不正確的十進制值:‘’列...’
我試過將' '
更改爲''
,'NULL'
和NULL
。這些似乎都不起作用。有什麼建議麼?