Question: OperationalError Traceback ( most recent call last ) Cell In [ 8 0 ] , line 2 3 1 5 cur = conn.cursor ( )

OperationalError
Traceback (most recent call last)
Cell In[80], line 23
15 cur = conn.cursor()
16}\mathrm{ cur.execute('''CREATE TABLE IF NOT EXISTS employees (
17 employee_id INTEGER PRIMARY KEY,
18 first_name TEXT,
(...)
22)''')
--->23 cur.executemany('INSERT OR IGNORE INTO employees VALUES (?,?,?,?,?)',
[(1, 'John', 'Doe', 'HR',50000),
(2, 'Jane', 'Smith', 'IT',75000),
(3, 'Mike', 'Brown', 'Finance', 62000),
(4, 'Emily', 'Davis', 'Marketing', 58000)])
conn.commit()
print("employees with a salary above 60000:")
OperationalError: table employees has 2 columns but 5 values were supplied
Dow below it is the full code
import sqlite3
conn = sqlite3.connect('company.db')
cur = conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS employees (
employee_id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
department TEXT,
salary REAL
)''')
cur.executemany('INSERT OR IGNORE INTO employees VALUES (?,?,?,?,?)',
[(1, 'John', 'Doe', 'HR',50000),
(2, 'Jane', 'Smith', 'IT',75000),
(3, 'Mike', 'Brown', 'Finance', 62000),
(4, 'Emily', 'Davis', 'Marketing', 58000)])
conn.commit()
print("employees with a salary above 60000:")
cur.execute('SELECT * FROM employees WHERE salary >60000')
employees_with_high_salary = cur.fetchall()
for row in employees_with_high_salary:
print(row)
cur.execute('UPDATE employees SET salary =65000 WHERE employee_id =3')
conn.commit()
cur.execute('DELETE FROM employees WHERE employee_id =4')
conn.commit
print("
Updated employees List:")
cur.execute('SELECT * FROM employees')
updated_employees = cur.fetchall()
for row in updated_employees:
print(row)
conn.close()
After the full code, I can't still see the issue on the code since I've tried to separate or find the missing columns, thank you.
OperationalError Traceback ( most recent call

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!