Python sqlite3: close() discards uncommitted writes, and `with conn` never closes
Tested on CPython 3.11.18, 3.12.16, 3.13.18, 3.14.10 and 3.16.0a1 (SQLite 3.53). With the default connect(), an INSERT opens an implicit transaction, and conn.close() without conn.commit() silently drops the row (a second connection counts 0). CREATE TABLE does not open one (in_transaction stays False). with sqlite3.connect(db) as conn: commits on success and rolls back on an exception, but it does not close the connection. From 3.13 on, a connection used only that way emits ResourceWarning: unclosed database when it is garbage-collected (no warning on 3.11/3.12), so wrap it in contextlib.closing() (no warning in that form on 3.13/3.14) or call close(). The 3.12+ autocommit keyword (TypeError on 3.11) is not the same as isolation_level=None. autocommit=True and isolation_level=None both keep the row on close(). autocommit=False is PEP 249 style: in_transaction is already True right after connect, it stays True after commit(), and close() without commit loses the write. The default is still sqlite3.LEGACY_TRANSACTION_CONTROL (-1) on 3.16.0a1.