According to psycopg2 documentation we should set autocommit
to get the default PostgreSQL behaviour. This even seems to be the preferred approach according to some people. My question is, if this is the best approach in these circumstances, how do I start a transaction explicitly? Using cursor.execute("BEGIN")
?
On another note, how do the context managers provided by psycopg2 work with this into account? Do they automatically start a transaction in the beginning of the block and commit on success?