Complete the code to import the SQLite library.
import [1]
We use the sqlite3 module to work with SQLite databases in Python.
Complete the code to connect to a database file named 'sensor_data.db'.
conn = sqlite3.[1]('sensor_data.db')
The connect function opens a connection to the SQLite database file.
Fix the error in the SQL command to create a table named 'readings' with columns 'id' (integer primary key) and 'value' (real).
cursor.execute('CREATE TABLE [1] (id INTEGER PRIMARY KEY, value REAL)')
The table should be named readings as per the requirement.
Fill both blanks to insert a sensor value into the 'readings' table using a parameterized query.
cursor.execute('INSERT INTO readings (value) VALUES ([1])', ([2],))
The question mark ? is a placeholder for the value, and sensor_value is the variable holding the data.
Fill all three blanks to commit the transaction, close the cursor, and close the connection.
conn.[1]() cursor.[2]() conn.[3]()
First, commit saves changes, then close the cursor and connection to free resources.