@@ -307,6 +307,59 @@ On Linux and macOS, you might use::
307307When your python-oracledb application is run, logging output is shown on the
308308terminal.
309309
310+ .. _enablingthin :
311+
312+ Explicitly Enabling python-oracledb Thin Mode
313+ =============================================
314+
315+ Python-oracledb defaults to Thin mode after determining that Thick mode is not
316+ going to be used. In one special case, you may wish to explicitly enable Thin
317+ mode to prevent Thick mode from being enabled later.
318+
319+ To allow application portability, the driver's internal logic allows
320+ applications to initally attempt
321+ :ref: `standalone connection <standaloneconnection >` creation in Thin mode, but
322+ then lets them :ref: `enable Thick mode <enablingthick >` if that connection is
323+ unsuccessful. An example is when trying to connect to an Oracle Database that
324+ turns out to be an old version that requires Thick mode. This heuristic means
325+ Thin mode is not enforced until the initial connection is successful. Since
326+ all connections must be the same mode, any second and subsequent concurrent
327+ Thin mode connection attempts will wait for the initial standalone connection
328+ to succeed, meaning the driver mode is no longer potentially changeable to
329+ Thick mode.
330+
331+ This heuristic delay does not impact:
332+
333+ - Single-threaded applications using standalone connections.
334+ - Single or multi-threaded applications using
335+ :ref: `connection pools <connpooling >` (even with ``min `` of 0).
336+ - Applications that have already called :func: `oracledb.init_oracle_client() `.
337+
338+ In the case that you want to open multiple standalone Thin mode connections in
339+ multiple threads, you may wish to force Thin mode by calling
340+ :meth: `oracledb.enable_thin_mode() ` as part of your application initialization.
341+ This avoids the mode heuristic delay. For example:
342+
343+ .. code-block :: python
344+
345+ import oracledb
346+
347+ oracledb.enable_thin_mode()
348+
349+ Once this method is called, then python-oracledb Thick mode cannot be enabled.
350+ If you call :func: `oracledb.init_oracle_client() `, you will get the following
351+ error::
352+
353+ DPY-2019: python-oracledb thick mode cannot be used because thin mode has
354+ already been enabled or a thin mode connection has already been created
355+
356+ If you have already enabled Thick mode by calling
357+ :func: `oracledb.init_oracle_client() ` and then call
358+ :meth: `oracledb.enable_thin_mode() `, you will get the following error::
359+
360+ DPY-2053: python-oracledb thin mode cannot be used because thick mode has
361+ already been enabled
362+
310363.. _optconfigfiles :
311364
312365Optional Oracle Configuration Files
0 commit comments