update all commands and havent tested

This commit is contained in:
Minh VU
2024-12-03 19:34:27 +01:00
parent fd1712226a
commit f221ed67db
5 changed files with 83 additions and 20 deletions

View File

@@ -103,5 +103,16 @@ def requete_postgres(str):
print("Cette requête prends:", temps, "seconde")
cursor.close()
conn.close()
except (psycopg2.DatabaseError, Exception) as error:
print(error)
def reset_database_postgres():
try:
with connect_postgres() as conn:
with conn.cursor() as cursor:
cursor.execute('DROP TABLE IF EXISTS flights,airlines,airports')
conn.commit()
cursor.close()
conn.close()
except (psycopg2.DatabaseError, Exception) as error:
print(error)