| 47 | |
| 48 | ==== `Environment.get_db_cnx` is deprecated #get_db_cnx |
| 49 | |
| 50 | Due to the new support for automated transaction management, `Connection` instances should no longer be acquired using the familiar `get_db_cnx` method, as it doesn't tell whether the connection will be used as part of a write transaction or purely for queries. Instead, one should use: |
| 51 | - `env.get_read_db` for obtaining a `Connection` suitable for read queries (i.e. `SELECT`) |
| 52 | - the `env.with_transaction` decorator, for using a `db` parameter in a transaction function which should be committed when the last such automatic transaction in the control flow completes successfully (see [#with_transaction details] further down) |
| 53 | |
| 54 | Using `env.get_db_cnx` still works, but any explicit transaction management will risk to prematurely end a higher level transaction set up via `with_transaction` at a previous level in the control flow. |