def create_results_tables(table_name, *args): """Creates a results table with the passed table name. *args is used only in the button widget to delete input inside the entry widget. *args: only needed to delete the gui entry_field after passing of data """ try: # creates 2 tables: 1. for saving results and 2. a copy of the selected database settings_obj = SettingVariables() selected_database = settings_obj.selected_database sql_m = SqlManager() sql_m.sql_create_results_table(table_name) sql_m.sql_create_database_copy(selected_database) except sqlite3.OperationalError as oe: print("Exception occurred in create_results_tables: " + str(oe))
def test_create_database_copy(self): """Creates a database copy table with certain name, queries all tables and checks that the queried last table_name equals the initial name. """ test_obj = TestVariables() selected_database = test_obj.selected_database self.setUpDatabase() sql_m = SqlManager() sql_m.sql_create_database_copy(selected_database) queried_table_name = sql_m.sql_get_all_tables() queried_table_name = [tables.table_name for tables in queried_table_name][-1][-1] self.assertEqual(selected_database + "_copy", queried_table_name) print("test_create_database_copy: successful") self.tearDownTable(selected_database) self.tearDownTable(selected_database + "_copy")
def setUpDatabaseCopy(): """Creates new copy of the selected database table.""" test_obj = TestVariables() selected_database = test_obj.selected_database sql_m = SqlManager() sql_m.sql_create_database_copy(selected_database)