A database connection is the active link software uses to execute SQL statements against a database and work with returned results. In Python, sqlite3.connect() opens a SQLite database file and creates the file when it does not yet exist. section 6.3.1
Store a connection in a database manager
class DatabaseManager: def __init__(self, database_filename): self.connection = sqlite3.connect(database_filename) def __del__(self): self.connection.close() Keeping the connection on the manager lets separate persistence operations reuse it, while cleanup closes it when the manager is destroyed. section 6.3.1
A connection supports persistence-layer operations by enabling:
- Adding, deleting, selecting, sorting, and counting records through SQL statements. section 6.3.1





