From 585ff1cd266ab987bd6e8b8d76206f00077aa4f6 Mon Sep 17 00:00:00 2001 From: miguel bermudo bayo Date: Wed, 14 Feb 2024 10:25:09 +0100 Subject: [PATCH] renaming of database tables removed --- silence/db/populate.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/silence/db/populate.py b/silence/db/populate.py index bdae2fd..fb85736 100644 --- a/silence/db/populate.py +++ b/silence/db/populate.py @@ -52,30 +52,31 @@ def create_database(): # after all database schema is created, we rename all columns and tables to be fully lowercase, this way we avoid any linux/windows weirdness. # there's a custom option when installing mysql server, it forces tablenames to be lowercase, maybe include that in the curriculum? + # SQL views maintain the nomenclature given in the query so renaming is out of the question. - get_table_names_q = f"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA= '{db_name}';" + # get_table_names_q = f"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA= '{db_name}';" - cursor.execute(get_table_names_q) - all_created_tables = cursor.fetchall() + # cursor.execute(get_table_names_q) + # all_created_tables = cursor.fetchall() - for table_name_tuple in all_created_tables: - table_name = table_name_tuple[0] + # for table_name_tuple in all_created_tables: + # table_name = table_name_tuple[0] - get_column_names_q = f"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{db_name}' AND TABLE_NAME = '{table_name}'" - cursor.execute(get_column_names_q) + # get_column_names_q = f"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{db_name}' AND TABLE_NAME = '{table_name}'" + # cursor.execute(get_column_names_q) - # table_column_names = cursor.fetchall() + # # table_column_names = cursor.fetchall() - # for column_name_tuple in table_column_names: - # column_name = column_name_tuple[0] + # # for column_name_tuple in table_column_names: + # # column_name = column_name_tuple[0] - # THIS STATEMENT REQUIRES THE NEW TYPE TO BE SPECIFIED, WHICH MIGHT BE A PROBLEM SINCE IT IS HARD TO GET I GUESS. - # rename_table_q = f"ALTER TABLE '{table_name}' CHANGE '{column_name}' '{column_name.lower()}' INT(11) NOT NULL;" - # cursor.execute(rename_table_q) + # # THIS STATEMENT REQUIRES THE NEW TYPE TO BE SPECIFIED, WHICH MIGHT BE A PROBLEM SINCE IT IS HARD TO GET I GUESS. + # # rename_table_q = f"ALTER TABLE '{table_name}' CHANGE '{column_name}' '{column_name.lower()}' INT(11) NOT NULL;" + # # cursor.execute(rename_table_q) - rename_table_q = f"ALTER TABLE {table_name} RENAME {table_name.lower()};" - cursor.execute(rename_table_q) + # rename_table_q = f"ALTER TABLE {table_name} RENAME {table_name.lower()};" + # cursor.execute(rename_table_q) - conn.commit() + # conn.commit() # Clean up when we're done cursor.close() \ No newline at end of file