我不知道问题出在哪里!有人可以帮助我吗?
cnx = mysql.connector.connect(用户='root',密码='suraj1697',主机='127.0.0.1',数据库='模型') mycursor = cnx.cursor() sql =“ INSERT INTO model2(length,host_length,path_length,fd_length,tld_length,count1,count2,count3,count4,count5,count6,count_http,count_https,count_www,count_digit,count_letter,count_dir,count_ip,count_short)VALUES(%d, %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ,%d)” 打印(SQL) 数据= [] 对于范围(1,32)中的i:
mycursor.execute("ALTER TABLE model2(id INT AUTO_INCREMENT PRIMARY KEY,lenght INT,host_length INT,path_length INT,fd_length INT,tld_length INT,count1 INT,count2 INT,count3 INT,count4 INT,count5 INT,count6 INT,count_http INT,count_https INT,count_www INT,count_digit INT,count_letter INT,count_dir INT,count_ip INT,count_short INT)")
#record=[int(urldata['url_length'][i]),int(urldata['hostname_length'][i]),int(urldata['path_length'][i]),int(urldata['fd_length'][i]),int(urldata['tld_length'][i]),int(urldata['count-'][i]),int(urldata['count@'][i]),int(urldata['count?'][i]),int(urldata['count%'][i]),int(urldata['count.'][i]),int(urldata['count='][i]),int(urldata['count-http'][i]),int(urldata['count-https'][i]),int(urldata['count-www'][i]),int(urldata['count-digits'][i]),int(urldata['count-letters'][i]),int(urldata['count_dir'][i]),int(urldata['use_of_ip'][i]),int(urldata['short_url'][i])]
record=[urldata['url_length'][i],urldata['hostname_length'][i], urldata['path_length'][i], urldata['fd_length'][i], urldata['tld_length'][i], urldata['count-'][i],urldata['count@'][i], urldata['count?'][i], urldata['count%'][i], urldata['count.'][i], urldata['count='][i], urldata['count-http'][i], urldata['count-https'][i],urldata['count-www'][i], urldata['count-digits'][i], urldata['count-letters'][i],urldata['count_dir'][i], urldata['use_of_ip'][i], urldata['short_url'][i]]
data.append(record)
打印(数据) mycursor.executemany(sql,data) cnx.commit()
答案 0 :(得分:0)
您输入的数据之一是numpy.int6。简单的解决方案是将值封装在int()中。正确的方法是使用numpy提供的astype()方法。
例如:
variable.astype(int)