This commit is contained in:
Rochas
2024-12-22 01:28:46 +01:00
parent 7aca856164
commit cfc4af1014
8 changed files with 201 additions and 14 deletions

37
main.py
View File

@@ -167,20 +167,25 @@ def readAndWriteMonetDB():
def randomWriteMonetDB(n):
global rapport
time = 0
min = 0
max = 0
for i in range(n):
requete = """INSERT INTO flights ("YEAR","MONTH","DAY","DAY_OF_WEEK","AIRLINE","FLIGHT_NUMBER","TAIL_NUMBER","ORIGIN_AIRPORT","DESTINATION_AIRPORT","SCHEDULED_DEPARTURE","DEPARTURE_TIME") VALUES ("""
requete += str(random.randint(2015,2016)) + "," + str(random.randint(1,12)) + "," + str(random.randint(1,31)) + "," + str(random.randint(1,7)) + ",'AA'," + str(random.randint(1,1000)) + ",'N1','JFK','LAX'," + str(random.randint(0,2400)) + "," + str(random.randint(0,2400)) + ");"
time = execMonetDB(requete)[0]
time += execMonetDB(requete)[0]
if(time<min or min == 0) :
min = time
if(time>max) :
max = time
time = time/n
result = "[MonetDB] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s"
result = "[MonetDB] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s" + "\n\tmin time = " + str(min) + "\n\tmax time = " + str(max)
rapport = rapport + "\n" + result
print(result)
def writeMonetDB():
randomWriteMonetDB(100)
randomWriteMonetDB(100)
randomWriteMonetDB(100)
randomWriteMonetDB(1000)
@@ -282,19 +287,23 @@ def readAndWritePostgreSQL():
def randomWritePostgreSQL(n):
global rapport
time = 0
min = 0
max = 0
for i in range(n):
requete = """INSERT INTO flights ("YEAR","MONTH","DAY","DAY_OF_WEEK","AIRLINE","FLIGHT_NUMBER","TAIL_NUMBER","ORIGIN_AIRPORT","DESTINATION_AIRPORT","SCHEDULED_DEPARTURE","DEPARTURE_TIME") VALUES ("""
requete += str(random.randint(2015,2016)) + "," + str(random.randint(1,12)) + "," + str(random.randint(1,31)) + "," + str(random.randint(1,7)) + ",'AA'," + str(random.randint(1,1000)) + ",'N1','JFK','LAX'," + str(random.randint(0,2400)) + "," + str(random.randint(0,2400)) + ");"
time = execPostgreSQL(requete)[0]
time += execPostgreSQL(requete)[0]
if(time<min or min == 0) :
min = time
if(time>max) :
max = time
time = time/n
result = "[PostgreSQL] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s"
result = "[PostgreSQL] requete (moyenne de " + str(n) +") : INSERT INTO flights random value \n\ttime = " + str(time) + " s" + "\n\tmin time = " + str(min) + "\n\tmax time = " + str(max)
rapport = rapport + "\n" + result
print(result)
def writePostgreSQL():
randomWritePostgreSQL(100)
randomWritePostgreSQL(100)
randomWritePostgreSQL(100)
randomWritePostgreSQL(1000)
@@ -346,8 +355,8 @@ if __name__ == '__main__':
print(rapport)
print("/////////////////////////////////////////////////////////////")
#date = datetime.now()
#nom_fichier = "result" + date.strftime("_%d_%m_%y_%H_%M_%S") + ".txt" #un nom de fichier unique pour ne pas écraser les anciens résultats
#with open(nom_fichier, 'w') as fichier:
# fichier.write(rapport)
date = datetime.now()
nom_fichier = "result" + date.strftime("_%d_%m_%y_%H_%M_%S") + ".txt" #un nom de fichier unique pour ne pas écraser les anciens résultats
with open(nom_fichier, 'w') as fichier:
fichier.write(rapport)
#