ok
This commit is contained in:
@@ -66,14 +66,16 @@ def create_tables_postgres():
|
||||
try:
|
||||
with connect_postgres() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
start_time = time.time()
|
||||
for command in sql_command_create_table:
|
||||
cursor.execute(command)
|
||||
conn.commit()
|
||||
end_time = time.time()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except (psycopg2.DatabaseError, Exception) as error:
|
||||
print(error)
|
||||
|
||||
return end_time-start_time
|
||||
|
||||
def create_data_postgres():
|
||||
sql_command_copy =(
|
||||
@@ -83,14 +85,16 @@ def create_data_postgres():
|
||||
try:
|
||||
with connect_postgres() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
start_time = time.time()
|
||||
for command in sql_command_copy:
|
||||
cursor.execute(command)
|
||||
conn.commit()
|
||||
end_time = time.time()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except (psycopg2.DatabaseError, Exception) as error:
|
||||
print(error)
|
||||
|
||||
return end_time - start_time
|
||||
|
||||
def requete_postgres(str):
|
||||
try:
|
||||
@@ -99,12 +103,12 @@ def requete_postgres(str):
|
||||
start = time.time()
|
||||
cursor.execute(str)
|
||||
conn.commit()
|
||||
temps = time.time() -start
|
||||
print("Cette requête prends:", temps, "seconde")
|
||||
end = time.time() -start
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except (psycopg2.DatabaseError, Exception) as error:
|
||||
print(error)
|
||||
return end-start
|
||||
|
||||
def reset_database_postgres():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user