22< html xmlns ="http://www.w3.org/1999/xhtml " xml:lang ="en " lang ="en ">
33< head >
44< meta charset ="utf-8 " />
5- < meta name ="generator " content ="Docutils 0.20.1 : https://docutils.sourceforge.io/ " />
5+ < meta name ="generator " content ="Docutils 0.21.2 : https://docutils.sourceforge.io/ " />
66< meta name ="viewport " content ="width=device-width, initial-scale=1 " />
77< title > DBUtils User's Guide</ title >
88< link rel ="stylesheet " href ="doc.css " type ="text/css " />
@@ -298,10 +298,13 @@ <h3>PersistentDB (persistent_db)</h3>
298298contrary to the intent of having persistent connections. Instead,
299299the connection will be automatically closed when the thread dies.
300300You can change this behavior by setting the < span class ="docutils literal "> closeable</ span > parameter.</ p >
301+ < aside class ="admonition warning ">
302+ < p class ="admonition-title "> Warning</ p >
301303< p > Note that you need to explicitly start transactions by calling the
302304< span class ="docutils literal "> begin()</ span > method. This ensures that the transparent reopening will be
303305suspended until the end of the transaction, and that the connection
304306will be rolled back before being reused by the same thread.</ p >
307+ </ aside >
305308< p > By setting the < span class ="docutils literal "> threadlocal</ span > parameter to < span class ="docutils literal "> threading.local</ span > , getting
306309connections may become a bit faster, but this may not work in all
307310environments (for instance, < span class ="docutils literal "> mod_wsgi</ span > is known to cause problems
@@ -374,7 +377,7 @@ <h3>PooledDB (pooled_db)</h3>
374377< pre class ="literal-block "> db = pool.dedicated_connection()</ pre >
375378< p > If you don't need it anymore, you should immediately return it to the
376379pool with < span class ="docutils literal "> db.close()</ span > . You can get another connection in the same way.</ p >
377- < p > < em > Warning:</ em > In a threaded environment, never do the following:</ p >
380+ < p > ⚠ Warning: In a threaded environment, never do the following:</ p >
378381< pre class ="literal-block "> pool.connection().cursor().execute(...)</ pre >
379382< p > This would release the connection too early for reuse which may be fatal
380383if the connections are not thread-safe. Make sure that the connection
@@ -390,11 +393,14 @@ <h3>PooledDB (pooled_db)</h3>
390393 with db.cursor() as cur:
391394 cur.execute(...)
392395 res = cur.fetchone()</ pre >
396+ < aside class ="admonition warning ">
397+ < p class ="admonition-title "> Warning</ p >
393398< p > Note that you need to explicitly start transactions by calling the
394399< span class ="docutils literal "> begin()</ span > method. This ensures that the connection will not be shared
395400with other threads, that the transparent reopening will be suspended
396401until the end of the transaction, and that the connection will be rolled
397402back before being given back to the connection pool.</ p >
403+ </ aside >
398404</ section >
399405</ section >
400406< section id ="advanced-usage ">
0 commit comments