Congratulations! You have completed your journey through database operations with Python. Let’s reflect on everything we have learned in this lesson:
- SQL, which stands for Structured Query Language, is a programming language designed to manage data stored in relational databases.
- Once you pull the SQLite data into your Python environment, you can analyze, visualize, change, and test this data.
- You may also edit a new or pre-existing SQLite database directly from a Python environment by connecting to the database using the
- In a database, a cursor allows us to traverse over the data one row at a time to call statements and return data. We can create a cursor object using the
- Using the
.execute()method in combination with a
CREATEclause, we can create a table within the SQLite database.
- Using the
.execute()method and an
INSERTclause, we can insert data into a pre-existing table.
- To insert multiple rows/records of data at once, we can use the
- To retrieve SQLite data, we can use the fetch methods;
- A Python for loop can be used to retrieve SQLite data. It can also be used to analyze already pulled data.
- After making changes to the SQLite database, we must commit the changes using the
- When we finish editing the SQLite database commit the changes, we can use the
.close()method to close the database connection.
Below, we have some more practice problems for you to test your knowledge.
Import the module
Create a connection object named
con that connects to the
Create a cursor object named
Retrieve and print the following row:
('Stephanie Bready', 37, 'stephB423', 30.0)
Save this row as
n_row. Click the hint if you feel stuck.
Close the connection to the database.