Deleting Records via SQL Query in Python
The DELETE command lets you delete records from a table. Its syntax is similar to what you learned earlier:
pythonquery = "DELETE FROM table WHERE condition"
With the DELETE command, it is necessary to use the commit method:
pythonwith connection.cursor(dictionary=True) as cursor:
cursor.execute(query)
connection.commit()
Задание 1
Remove user with id equal to 7.
Задание 2
Remove all users who are 23 years old.
Задание 3
Remove all users whose id is greater than 5 and salary is greater than or equal to 900.
Задание 4
Delete all users.