1 · Learn and explore
Study this example, identify inputs and outputs, then trace the key variables. Run and adapt it in Python 3.
import sqlite3
with sqlite3.connect(':memory:') as connection:
connection.execute('CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT NOT NULL, author TEXT NOT NULL)')
books = [('Algorithms Made Clear', 'A. Writer'), ('Learning Python', 'B. Author')]
connection.executemany('INSERT INTO books(title, author) VALUES (?, ?)', books)
rows = connection.execute('SELECT title FROM books ORDER BY title').fetchall()
