def read_db_for_shows(): '''Read show_db SQLite database and populate show list''' try: db = sqlite3.connect('data/show_db.db') cur = db.cursor() cur.execute("PRAGMA foreign_keys=ON") # Fetch some data, using the cursor. This returns another cursor object # that can be iterated over for row in cur.execute('select * from show'): #ui.message(row) update_ind = g.BLANK show = Show(row[1], row[2], row[3], update_ind) show.set_id(row[0]) g.show_list.append(show) # ui.message('************* Shows **************') # ui.message(g.show_list) # ui.message('') except sqlite3.Error as e: # As we are reading, no changes to roll back print('Error reading from database', e) logging.error('Database error {}'.format(e)) traceback.print_exc() finally: db.close()
def modify_shows_record(show_index, show_id): print('Your record to modify is:') print(g.show_list[show_index]) while True: clear() showname = input('Enter the name of the Show: ') showlocation = input('Enter the location of the Show (city/town name): ') showdate = input('Enter the Show Date (YYYY-MM-DD): ') message('You entered {} {} {} '.format(showname, showlocation, showdate)) check = input('Is this correct? "y" or "n": ') if check.lower() == 'y': break update_ind = g.MODIFY show = Show(showname, showlocation, showdate, update_ind) # generate a new replacement object show.set_id(show_id) g.show_list.insert(show_index, show) # insert the object back into the list where it came from for item in g.show_list: print(item)