How to update and delete records in a SQLite database?

75 views

How to update and delete records in a SQLite database?

How to update and delete records in a SQLite database?

solveurit24@gmail.com Changed status to publish February 13, 2025
0

Use UPDATE and DELETE statements.

import sqlite3

conn = sqlite3.connect('mydatabase.db')
cursor = conn.cursor()
cursor.execute("UPDATE users SET name = 'Bob' WHERE id = 1")
cursor.execute("DELETE FROM users WHERE id = 2")
conn.commit()
conn.close()

solveurit24@gmail.com Changed status to publish February 13, 2025
0
You are viewing 1 out of 1 answers, click here to view all answers.