【问题标题】:InterfaceError: Failed executing the operation; Python type numpy.int64 cannot be convertedInterfaceError:执行操作失败; Python 类型 numpy.int64 无法转换
【发布时间】:2019-11-05 22:24:51
【问题描述】:

我不知道问题出在哪里!有人可以帮助我吗?

cnx=mysql.connector.connect(user='root',password='suraj1697',host='127.0.0.1',database='model') 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) 值(%d, %d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ,%d)" 打印(sql) 数据=[] for i in range(1, 32):

mycursor.execute('创建数据库模型')

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,数据) cnx.commit()

【问题讨论】:

    标签: python mysql-workbench


    【解决方案1】:

    您的输入数据之一是 numpy.int6 类型。简单的解决方案是将值封装在 int() 中。正确的方法是使用numpy提供的astype()方法。

    例如:

    变量.astype(int)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-04
      • 2019-10-03
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2012-10-12
      • 2014-02-03
      相关资源
      最近更新 更多