A database cursor executes SQL statements and provides access to their results. Query cursors let you iterate through returned rows; non-query statements produce no results. section 6.3.1
A reusable execution method can create a cursor, execute a statement, and return the cursor. Wrapping these steps in a transaction helps preserve the database’s last working state when execution fails. section 6.3.1
def _execute(self, statement, values=None): #1
with self.connection:
cursor = self.connection.cursor()
cursor.execute(statement, values or []) #2
return cursor
The reusable SQLite helper accepts SQL and optional values, executes it through a cursor inside a transaction, and returns the cursor. section 6.3.1






