Introducing a PEP 249 compliant transaction behaviour to sqlite3

Just to confirm, this is the usual meaning of Connection.autocommit (and a draft of what I’ll kick off the process with):

Attribute to query and set the autocommit mode of the connection.

Returns True if the connection is operating in autocommit (non-transactional) mode. Returns False is the connection is operating in manual commit (transactional) mode.

Setting the attribute to True or False adjusts the connection’s mode accordingly.

The details around changing the value are database dependent, e.g. changing from True to False will usually start a new transaction, while changing from False to True will usually cause the current transaction to be committed. However, it is also possible that a database raises an error in case there are pending changes to be committed. To prevent the latter case, it is best to explicitly commit or rollback the current transaction before switching on autocommit mode on the connection.

It may make sense to have the DB API modules enforce the behavior described as “usual” behavior.

2 Likes