correction monetDB

This commit is contained in:
trochas
2024-12-11 12:33:41 +01:00
parent 91cd5d07d3
commit 2492c11e18
2 changed files with 22 additions and 14 deletions

View File

@@ -69,51 +69,63 @@ def create_table_monetdb():
connect = connect_monetdb()
with connect[0] as conn:
with connect[1] as cursor:
start_time = time.time()
cursor.execute(createAirline)
cursor.execute(createAirports)
cursor.execute(createFlights)
conn.commit()
end_time = time.time()
cursor.close()
conn.close()
except(pymonetdb.DatabaseError,Exception) as error:
print(error)
return end_time-start_time
def load_data_monetdb():
try:
connect = connect_monetdb()
with connect[0] as conn:
with connect[1] as cursor:
start_time = time.time()
cursor.execute(peuplementAirports)
cursor.execute(peuplementAirlines)
cursor.execute(peuplementFlights)
conn.commit()
end_time = time.time()
cursor.close()
conn.close()
except(pymonetdb.DatabaseError,Exception) as error:
print(error)
return end_time-start_time
def requete_monetdb(str):
try:
connect=connect_monetdb()
with connect[0] as conn:
with connect[1] as cursor:
start_time = time.time()
cursor.execute(str)
conn.commit()
end_time = time.time()
cursor.close()
conn.close()
except(pymonetdb.DatabaseError, Exception) as error:
print(error)
return end_time-start_time
def reset_data_monetdb():
try:
connect = connect_monetdb()
with connect[0] as conn:
with connect[1] as cursor:
start_time = time.time()
cursor.execute("DROP TABLE IF EXISTS airlines")
cursor.execute("DROP TABLE IF EXISTS airports")
cursor.execute("DROP TABLE IF EXISTS flights")
conn.commit()
end_time = time.time()
cursor.close()
conn.close()
except(pymonetdb.DatabaseError, Exception) as error:
print(error)
print(error)
return end_time-start_time