Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Updating rows, deleting rows, and more WHERE clauses

To update or delete existing rows, we use the UPDATE and DELETE FROM keywords in conjunction with a WHERE clause to select the affected rows.

Deleting is fairly simple looks like this:

DELETE FROM instruments WHERE id=4;

The DELETE FROM command will delete any rows that match the WHERE conditions. In this case, we match the primary key to ensure only one row is deleted. If no rows match the WHERE conditions, no rows will be deleted. Note, however, that the WHERE clause is technically optional: DELETE FROM instruments will simply delete all rows in the table.

Updating is similar, except it includes a SET clause to specify new column values as follows:

UPDATE musicians SET main_instrument=3 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content