84 | | === Database API Changes === |
85 | | |
86 | | |
87 | | ==== `Environment.get_db_cnx` has been removed #get_db_cnx |
88 | | |
89 | | Following the [../0.12#get_db_cnx deprecation] made in 0.12, using `Environment.get_db_cnx` for obtaining a database connection has now been removed. |
90 | | TODO |
91 | | |
92 | | One should now only use the //context managers// for retrieving a database Connection |
93 | | in read or write mode. |
94 | | - a **read-only** Connection can be used to form queries: |
95 | | {{{#!python |
96 | | with env.db_query as db: |
97 | | ... |
98 | | }}} |
99 | | a `db` instance obtained the above way should only be used for executing //SELECT// |
100 | | queries |
101 | | - a **writable** Connection can be used to modify the database content in a transaction: |
102 | | {{{#!python |
103 | | with env.db_transaction as db: |
104 | | ... |
105 | | }}} |
106 | | a `db` instance obtained the above way can be used to execute //INSERT/UPDATE/DELETE// |
107 | | queries; they will be committed when the last such automatic transaction |
108 | | in the control flow completes successfully. See DatabaseApi for the full details. |
109 | | |
110 | | ==== `Environment.db_query()` and `Environment.db_transaction()` ^[source:trunk/trac/env.py@#Lnum (1.0)]^ ==== #with_transaction |
111 | | |
112 | | // |
113 | | The `@with_transaction(env)` / `@env.with_transaction()` decorators introduced in 0.12 and deprecated in Trac 1.0 are now even more deprecated ;-) They will be removed in 1.3.1. |
114 | | // |
115 | | |