debug
This commit is contained in:
44
MonetDB.py
44
MonetDB.py
@@ -66,52 +66,56 @@ def connect_monetdb():
|
||||
|
||||
def create_table_monetdb():
|
||||
try:
|
||||
with connect_monetdb()[0] as conn:
|
||||
with connect_monetdb()[1] as cursor:
|
||||
connect = connect_monetdb()
|
||||
with connect[0] as conn:
|
||||
with connect[1] as cursor:
|
||||
cursor.execute(createAirline)
|
||||
cursor.execute(createAirports)
|
||||
cursor.execute(createFlights)
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except(pymonetdb.DatabaseError,Exception) as error:
|
||||
print(error)
|
||||
|
||||
def load_data_monetdb():
|
||||
try:
|
||||
with connect_monetdb()[0] as conn:
|
||||
with connect_monetdb()[1] as cursor:
|
||||
connect = connect_monetdb()
|
||||
with connect[0] as conn:
|
||||
with connect[1] as cursor:
|
||||
cursor.execute(peuplementAirports)
|
||||
cursor.execute(peuplementAirlines)
|
||||
cursor.execute(peuplementFlights)
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except(pymonetdb.DatabaseError,Exception) as error:
|
||||
print(error)
|
||||
|
||||
def requete_monetdb(str):
|
||||
try:
|
||||
with connect_monetdb()[0] as conn:
|
||||
with connect_monetdb()[1] as cursor:
|
||||
connect=connect_monetdb()
|
||||
with connect[0] as conn:
|
||||
with connect[1] as cursor:
|
||||
cursor.execute(peuplementAirports)
|
||||
cursor.execute(peuplementAirlines)
|
||||
cursor.execute(peuplementFlights)
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except(pymonetdb.DatabaseError, Exception) as error:
|
||||
print(error)
|
||||
|
||||
def reset_data_monetdb():
|
||||
try:
|
||||
with connect_monetdb()[0] as conn:
|
||||
with connect_monetdb()[1] as cursor:
|
||||
connect = connect_monetdb()
|
||||
with connect[0] as conn:
|
||||
with connect[1] as cursor:
|
||||
cursor.execute("DROP TABLE IF EXISTS airlines")
|
||||
cursor.execute("DROP TABLE IF EXISTS airports")
|
||||
cursor.execute("DROP TABLE IF EXISTS flights")
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
except(pymonetdb.DatabaseError, Exception) as error:
|
||||
print(error)
|
||||
30
main.py
30
main.py
@@ -22,14 +22,6 @@ requeteCreateTablePostgreSQL = """CREATE TABLE flights10 AS SELECT * FROM FLIGHT
|
||||
requeteDeletePostgreSQL = """DELETE FROM flights WHERE "DAY" > 10"""
|
||||
requeteInsertPostgreSQL = """INSERT INTO flights SELECT * FROM flights10"""
|
||||
|
||||
def initMonetDB():
|
||||
reset_data_monetdb()
|
||||
create_table_monetdb()
|
||||
load_data_monetdb()
|
||||
|
||||
def execMonetDB(conn,cursor,str):
|
||||
requete_monetdb(conn,cursor, str)
|
||||
|
||||
def display_table(data, headers):
|
||||
max_len = max(len(header) for header in headers)
|
||||
print(" | ".join(header.ljust(max_len) for header in headers))
|
||||
@@ -38,16 +30,10 @@ def display_table(data, headers):
|
||||
for row in data:
|
||||
print(" | ".join(header.ljust(max_len) for header in row))
|
||||
|
||||
|
||||
#start_time = time.time()
|
||||
#end_time = time.time()
|
||||
#print(end_time - start_time)
|
||||
|
||||
|
||||
def initMonetDB():
|
||||
reset_data_monetdb()
|
||||
start_time = time.time()
|
||||
create_table_monetdb()
|
||||
#create_table_monetdb()
|
||||
end_time = time.time()
|
||||
print("[MonetDB] creat table: time = ", (end_time - start_time), "s")
|
||||
|
||||
@@ -63,15 +49,9 @@ def execMonetDB(str):
|
||||
print("[MonetDB] requete :", str , "\n time = ", (end_time - start_time), "s")
|
||||
|
||||
def runMonetDB():
|
||||
conn, cursor =connect_monetdb()
|
||||
start = time.time()
|
||||
initMonetDB()
|
||||
print(time.time() - start)
|
||||
execMonetDB(conn,cursor,requeteSelect1MonetDB)
|
||||
execMonetDB(conn,cursor,requeteSelect2MonetDB)
|
||||
execMonetDB(conn,cursor,requeteSelect3MonetDB)
|
||||
execMonetDB(conn,cursor,requeteSelect4MonetDB)
|
||||
|
||||
reset_data_monetdb()
|
||||
create_table_monetdb()
|
||||
load_data_monetdb()
|
||||
#execMoneDB(conn,cursor,requeteSelect1MonetDB)
|
||||
|
||||
def runPostgreSQL():
|
||||
@@ -81,5 +61,5 @@ def runPostgreSQL():
|
||||
#requete_postgres(str)
|
||||
|
||||
if __name__ == '__main__':
|
||||
runMonetDB()
|
||||
initMonetDB()
|
||||
#runPostgreSQL()
|
||||
|
||||
Reference in New Issue
Block a user