Hint: Ensure to strip all strings so there is no space in them DO NOT use StudentID from…
- User
Hint: Ensure to strip all strings so there is no space in them
DO NOT use StudentID from the non_normalized table. Let the normalized table automatically handle StudentID.
def create_connection(db_file, delete_db=False): import os if delete_db and os.path.exists(db_file): os.remove(db_file)
codeconn = None try: conn = sqlite3.connect(db_file) conn.execute("PRAGMA foreign_keys = 1") except Error as e: print(e) return conndef create_table(conn, create_table_sql): try: c = conn.cursor() c.execute(create_table_sql) except Error as e: print(e)
def execute_sql_statement(sql_statement, conn): cur = conn.cursor() cur.execute(sql_statement)
coderows = cur.fetchall() return rowsconn_non_normalized = create_connection('non_normalized.db')
sql_statement = "select * from Students;"
df = pd.read_sql_query(sql_statement, conn_non_normalized)
display(df)
def normalize_database(non_normalized_db_filename):
Normalize 'non_normalized.db'
Call the normalized database 'normalized.db'
Function Output: No outputs
Requirements:
Create four tables
Degrees table has one column:
[Degree] column is the primary key
Exams table has two columns:
[Exam] column is the primary key column
[Year] column stores the exam year
Students table has four columns:
[StudentID] primary key column
[First_Name] stores first name
[Last_Name] stores last name
[Degree] foreign key to Degrees table
StudentExamScores table has four columns:
[PK] primary key column,
[StudentID] foreign key to Students table,
[Exam] foreign key to Exams table ,
[Score] exam score
code### BEGIN SOLUTION ### END SOLUTIONnormalize_database('non_normalized.db')
conn_normalized = create_connection('normalized.db')
give accurate code for the above requirements
- Assistant