diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2020-09-05 19:15:01 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2020-09-05 19:16:50 +0100 |
commit | 195b2549371ce4a2e8f1f9c94f06e921c1cda387 (patch) | |
tree | 62eb467b153ee506f3d15b438812cc076fabac21 | |
parent | 0ee9d840a108aeccd6a0492c9fe2a924179823c1 (diff) | |
download | psycopg2-195b2549371ce4a2e8f1f9c94f06e921c1cda387.tar.gz |
Improve wording around transactions behaviour closing connections
The transaction is not rolled back by the connection, rather discarded
by the server.
Close #1135.
-rw-r--r-- | doc/src/usage.rst | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/doc/src/usage.rst b/doc/src/usage.rst index 7d0e700..5239518 100644 --- a/doc/src/usage.rst +++ b/doc/src/usage.rst @@ -750,10 +750,14 @@ until a call to the `~connection.rollback()` method. The connection is responsible for terminating its transaction, calling either the `~connection.commit()` or `~connection.rollback()` method. Committed -changes are immediately made persistent into the database. Closing the -connection using the `~connection.close()` method or destroying the -connection object (using `!del` or letting it fall out of scope) -will result in an implicit rollback. +changes are immediately made persistent into the database. If he connection +is closed (using the `~connection.close()` method) or destroyed (using `!del` +or letting it falling out of scope) while a transaction is in progress, the +server will discard the transaction. However doing so is not adviceable: +middleware such as PgBouncer_ may see the connection closed uncleanly and +dispose of it. + +.. _PgBouncer: http://www.pgbouncer.org/ It is possible to set the connection in *autocommit* mode: this way all the commands executed will be immediately committed and no rollback is possible. A |