From b0f78cff48cc5bd4d5d6a8d0237b4ccb4c994377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sun, 2 Apr 2023 08:48:32 -0300 Subject: [PATCH] =?UTF-8?q?O=20que=20=C3=A9=20CRUD=20+=20DELETE=20com=20e?= =?UTF-8?q?=20sem=20WHERE=20no=20SQLite3=20do=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula205/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aula205/main.py b/aula205/main.py index 6e59841..9bf8609 100644 --- a/aula205/main.py +++ b/aula205/main.py @@ -9,10 +9,15 @@ TABLE_NAME = 'customers' connection = sqlite3.connect(DB_FILE) cursor = connection.cursor() +# CRUD - Create Read Update Delete +# SQL - INSERT SELECT UPDATE DELETE + # CUIDADO: fazendo delete sem where cursor.execute( f'DELETE FROM {TABLE_NAME}' ) + +# DELETE mais cuidadoso cursor.execute( f'DELETE FROM sqlite_sequence WHERE name="{TABLE_NAME}"' ) @@ -51,7 +56,6 @@ cursor.executemany(sql, ( {'nome': 'Joana', 'peso': 5}, )) connection.commit() - cursor.close() connection.close()