微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sqlite3.OperationalError:表响应有5列,但提供了6个值-tkinter

如何解决sqlite3.OperationalError:表响应有5列,但提供了6个值-tkinter

即使在网上看了几个小时,我的一个sqlite数据库表也无法解决错误。我还尝试删除数据库并从一个数据库开始,但这没有用。

错误:第1行中的第90行 c.execute(“插入响应值(:company,:roles,:interview,:offer,:wage_offered,:start_date)”, sqlite3.OperationalError:表响应有5列,但提供了6个值

但是有6列,所以我不明白为什么出现此错误

submit1函数代码发布在下面:

#create submit function for 
def submit1():
    # Create a databse or connect to one
    connection = sqlite3.connect('jobtracker.db')


 #Create a cursor
    c = connection.cursor()

    # Insert into table
    c.execute("INSERT INTO responses VALUES (:company,:roles,:interview,:offer,:wage_offered,:start_date)",{
                'company': company1.get(),'roles': role1.get(),'interview': interview.get(),'offer': offer.get(),'wage_offered': wage_offered.get(),'start_date': start_date.get()
            })

    # Commit changes
    connection.commit()

# Close connection
    connection.close()

这是数据库代码

#Creating database
conn = sqlite3.connect('jobtracker.db')

c = conn.cursor()

#Creating tables for database
c.execute("""CREATE TABLE IF NOT EXISTS applications (
        company text,role text,industry text,location text,wage_min integer,wage_max integer,start_date integer,status text
        )""")

c.execute("""CREATE TABLE IF NOT EXISTS responses (
        company text,interview integer,offer integer
        wage_offered integer,start_date integer
        )""")


conn.commit()

conn.close()

#create submit function for 
def submit():
    # Create a databse or connect to one
    connection = sqlite3.connect('jobtracker.db')


 #Create a cursor
    c = connection.cursor()

    # Insert into table
    c.execute("INSERT INTO applications VALUES (:company,:industry,:location,:wage_min,:wage_max,:start_date,:status)",{
                'company': company.get(),'roles': role.get(),'industry': industry.get(),'location': location.get(),'wage_min': wage_min.get(),'wage_max': wage_max.get(),'start_date': start_date.get(),'status': status.get()
            })

    # Commit changes
    connection.commit()

# Close connection
    connection.close()

谢谢。

解决方法

我认为表格只有5个字段 您正在尝试插入6个字段

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。