@@ -32,32 +32,28 @@ Oracle Client and Oracle Database communicate.
32
32
There are two ways to create a connection to Oracle Database using
33
33
python-oracledb:
34
34
35
- * **Standalone connections **: :ref: `Standalone connections <standaloneconnection >`
36
- are useful when the application needs a single connection to a database.
37
- Connections are created by calling :meth: `oracledb.connect() `.
38
-
39
- * **Pooled connections **: :ref: `Connection pooling <connpooling >` is important for
40
- performance when applications frequently connect and disconnect from the database.
41
- Pools support Oracle's :ref: `high availability <highavailability >` features and are
42
- recommended for applications that must be reliable. Small pools can also be
43
- useful for applications that want a few connections available for infrequent
44
- use. Pools are created with :meth: `oracledb.create_pool() ` at application
45
- initialization time, and then :meth: `ConnectionPool.acquire() ` can be called to
46
- obtain a connection from a pool.
35
+ * **Standalone connections **: :ref: `Standalone connections
36
+ <standaloneconnection>` are useful when the application needs a single
37
+ connection to a database. Connections are created by calling
38
+ :meth: `oracledb.connect() `. For :ref: `asyncio <asyncio >`, use
39
+ :meth: `oracledb.connect_async() ` instead, see :ref: `connasync `.
40
+
41
+ * **Pooled connections **: :ref: `Connection pooling <connpooling >` is important
42
+ for performance when applications frequently connect and disconnect from the
43
+ database. Pools support Oracle's :ref: `high availability <highavailability >`
44
+ features and are recommended for applications that must be reliable. Small
45
+ pools can also be useful for applications that want a few connections
46
+ available for infrequent use. Pools are created with
47
+ :meth: `oracledb.create_pool() ` at application initialization time, and then
48
+ :meth: `ConnectionPool.acquire() ` can be called to obtain a connection from a
49
+ pool. For :ref: `asyncio <asyncio >`, use :meth: `oracledb.create_pool_async() `
50
+ and :meth: `AsyncConnectionPool.acquire() ` instead, see :ref: `asyncconnpool `.
47
51
48
52
Many connection behaviors can be controlled by python-oracledb connection
49
53
options. Other settings can be configured in :ref: `optnetfiles ` or in
50
54
:ref: `optclientfiles `. These include limiting the amount of time that opening
51
55
a connection can take, or enabling :ref: `network encryption <netencrypt >`.
52
56
53
- .. note ::
54
-
55
- Creating a connection in python-oracledb Thin mode always requires a
56
- connection string, or the database host name and service name, to be
57
- specified. The Thin mode cannot use "bequeath" connections and does not
58
- reference Oracle environment variables ``ORACLE_SID ``, ``TWO_TASK ``,
59
- or ``LOCAL ``.
60
-
61
57
.. _standaloneconnection :
62
58
63
59
Standalone Connections
@@ -287,6 +283,14 @@ For more information about naming methods, see the `Database Net Services
287
283
Administrator's Guide
288
284
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-E5358DEA-D619-4B7B-A799-3D2F802500F1> `__.
289
285
286
+ .. note ::
287
+
288
+ Creating a connection in python-oracledb Thin mode always requires a
289
+ connection string, or the database host name and service name, to be
290
+ specified. The Thin mode cannot use "bequeath" connections and does not
291
+ reference Oracle environment variables ``ORACLE_SID ``, ``TWO_TASK ``,
292
+ or ``LOCAL ``.
293
+
290
294
.. _easyconnect :
291
295
292
296
Easy Connect Syntax for Connection Strings
@@ -1883,6 +1887,10 @@ creation calls. If you call :meth:`ConnectParams.parse_connect_string()`, the
1883
1887
registered protocol hook method will be called but the parameter hook will not
1884
1888
be.
1885
1889
1890
+ ..
1891
+ Note to doc writers: do not change the following heading because it is used
1892
+ for a link emitted by ldap_hook() in src/oracledb/builtin_hooks.py
1893
+
1886
1894
.. _ldapconnections :
1887
1895
1888
1896
LDAP Directory Naming
@@ -2061,8 +2069,17 @@ Connection Pooling
2061
2069
==================
2062
2070
2063
2071
Connection pooling can significantly improve application performance and
2064
- scalability, allows resource sharing, and lets applications use advanced Oracle
2065
- High Availability features.
2072
+ scalability by allowing resource sharing. Pools also let applications use
2073
+ optional advanced Oracle High Availability features.
2074
+
2075
+ Opening a connection to a database can be expensive: the connection string must
2076
+ be parsed, a network connection must be established, the Oracle Database
2077
+ network listener needs to be invoked, user authentication must be performed, a
2078
+ database server process must be created, and session memory must be allocated
2079
+ (and then the process is destroyed when the connection is closed). Connection
2080
+ pools remove the overhead of repeatedly opening and closing :ref: `standalone
2081
+ connections <standaloneconnection>` by establishing a pool of open connections
2082
+ that can be reused throughout the life of an application process.
2066
2083
2067
2084
The pooling solutions available to python-oracledb applications are:
2068
2085
@@ -2092,12 +2109,12 @@ The pooling solutions available to python-oracledb applications are:
2092
2109
2093
2110
- `Proxy Resident Connection Pooling (PRCP)
2094
2111
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-E0032017-03B1-
2095
- 4F14-AF9B-BCC87C982DA8> `__: This is connection pooling handled by a dedicated
2096
- mid-tier connection proxy, `CMAN-TDM <https://download.oracle.com/
2097
- ocomdocs/global/CMAN_TDM_Oracle_DB_Connection_Proxy_for_scalable_
2098
- apps .pdf> `__.
2112
+ 4F14-AF9B-BCC87C982DA8> `__: This is connection pooling handled by Oracle's
2113
+ mid-tier connection proxy solution , `CMAN-TDM <https://download.oracle.com/
2114
+ ocomdocs/global/
2115
+ CMAN_TDM_Oracle_DB_Connection_Proxy_for_scalable_apps .pdf> `__.
2099
2116
2100
- This is useful for applications taking advantage of CMAN-TDM.
2117
+ PRCP is useful for applications taking advantage of CMAN-TDM.
2101
2118
2102
2119
- :ref: `implicitconnpool `: This can add pooling benefits to applications that
2103
2120
connect when they start, and only close the connection when the application
@@ -2242,6 +2259,11 @@ server process to be released, use :meth:`ConnectionPool.drop()`:
2242
2259
2243
2260
pool.drop(connection)
2244
2261
2262
+ Avoid doing this unnecessarily because it shrinks the pool. A future
2263
+ :meth: `~ConnectionPool.acquire() ` call may suffer the overhead of establishing
2264
+ a new connection to the database, instead of being able to reuse a connection
2265
+ already available in the pool.
2266
+
2245
2267
Closing a Connection Pool
2246
2268
+++++++++++++++++++++++++
2247
2269
0 commit comments