I have this error with one of my sqlite database tables that I cannot solve, even after looking online for hours. I have also tried deleting the database and starting with a new one but this did not work.
The Error: line 90, in submit1 c.execute("INSERT INTO responses VALUES (:company, :roles, :interview, :offer, :wage_offered, :start_date)", sqlite3.OperationalError: table responses has 5 columns but 6 values were supplied
However there are 6 columns so I do not understand why this error is cropping up.
the submit1 function Code is posted below:
#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()
And here is the code for the database:
#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,
role 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, :roles, :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()
Thank you in advance.
offer integer
– Mike67CREATE TABLE IF NOT EXISTS
in your table. You've probably updated your code to add a new collumn, but the database did not update since the table already exists. – Countour-IntegralCREATE TABLE
statement has a syntax error in it, so that can't be the code that created the table. – Martijn PietersDESCRIBE <tablename>
of your table, and if out if you actually have 6 column or is it 5 – Cool Cloud