import sqlite3 from prettytable import from_db_cursor # copy and paste your SQL queries into each of the below variables # note: do NOT rename variables Q1 = ''' ''' Q2 = ''' ''' Q3 = ''' ''' Q4 = ''' ''' Q5 = ''' ''' Q6 = ''' ''' Q7 = ''' ''' Q8 = ''' ''' Q9 = ''' ''' Q10 = ''' ''' ################################# # do NOT modify below this line # ################################# # open a database connection to our local flights database def connect_database(database_path): global conn conn = sqlite3.connect(database_path) def get_all_query_results(debug_print = True): all_results = [] for q, idx in zip([Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10], range(1, 11)): result_strings = ("The result for Q%d was:\n%s\n\n" % (idx, from_db_cursor(conn.execute(q)))).splitlines() all_results.append(result_strings) if debug_print: for string in result_strings: print string return all_results if __name__ == "__main__": connect_database('flights.db') query_results = get_all_query_results()