17.7 Practical Exercises
Exercise 17.7.1
Connect to the SQLite database exercise.db (you may need to create it first), create a table named students with the columns id, name, and age, then insert the following records:
Remember to close your database connection after performing these operations.
Exercise 17.7.2
Using the same students table you created in the previous exercise, write a Python function that receives a student's ID as a parameter and returns the student's name. Make sure to handle any exceptions that might occur if the ID is not found in the table.
Exercise 17.7.3
Update the age of 'John Doe' in the students table to 25 using Python and the sqlite3 module. Verify your update by querying the table.
Exercise 17.7.4
Write a Python function to delete a student record from the students table based on the student's ID. Remember to handle exceptions if the student ID does not exist.
Exercise 17.7.5
Write a Python script using psycopg2 module...