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