O que é CRUD + DELETE com e sem WHERE no SQLite3 do Python
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user