# Recommended way - automatically handles commit/close def best_practice_example(): with sqlite3.connect('my_database.db') as conn: cursor = conn.cursor() # Your queries here cursor.execute("SELECT * FROM users WHERE age > ?", (18,)) results = cursor.fetchall()
This will open the SQLite3 shell. Create a table called users with the following schema: sqlite3 tutorial query python fixed