@@ -50,15 +50,19 @@ begins with ``python-oracledb thk``. See :ref:`vsessconinfo`.
5050
5151.. _libinit :
5252
53- Locating the Oracle Client Libraries
54- ------------------------------------
53+ Setting the Oracle Client Library Directory
54+ -------------------------------------------
5555
5656When :meth: `~oracledb.init_oracle_client() ` is called, python-oracledb
5757dynamically loads Oracle Client libraries using a search heuristic. Only the
58- first set of libraries found are loaded. The libraries can be in an
59- installation of Oracle Instant Client, in a full Oracle Client installation, or
60- in an Oracle Database installation (if Python is running on the same machine as
61- the database). The versions of Oracle Client and Oracle Database do not have
58+ first set of libraries found are loaded. The libraries can be:
59+
60+ - in an installation of Oracle Instant Client
61+ - or in a full Oracle Client installation
62+ - or in an Oracle Database installation (if Python is running on the same
63+ machine as the database).
64+
65+ The versions of Oracle Client and Oracle Database do not have
6266to be the same. For certified configurations see Oracle Support's `Doc ID
6367207303.1
6468<https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1> `__.
@@ -68,150 +72,151 @@ libraries.
6872
6973.. _wininit :
7074
71- * On Windows, python-oracledb Thick mode can be enabled as follows:
75+ Setting the Oracle Client Directory on Windows
76+ ++++++++++++++++++++++++++++++++++++++++++++++
7277
73- - By passing the ``lib_dir `` parameter in a call to
74- :meth: `~oracledb.init_oracle_client() `, for example:
78+ On Windows, python-oracledb Thick mode can be enabled as follows:
7579
76- .. code-block :: python
80+ - By passing the ``lib_dir `` parameter in a call to
81+ :meth: `~oracledb.init_oracle_client() `, for example:
7782
78- import oracledb
83+ .. code-block :: python
7984
80- oracledb.init_oracle_client( lib_dir = r " C: \i nstantclient_19_14 " )
85+ import oracledb
8186
82- This directory should contain the libraries from an unzipped Instant
83- Client 'Basic' or 'Basic Light' package. If you pass the library
84- directory from a full client or database installation, such as Oracle
85- Database "XE" Express Edition, then you will need to have previously set
86- your environment to use that same software installation. Otherwise, files
87- such as message files will not be located and you may have library
88- version clashes. On Windows, when the path contains backslashes, use a
89- 'raw' string like ``r"C:\instantclient_19_14" ``.
87+ oracledb.init_oracle_client(lib_dir = r " C:\i nstantclient_19_14" )
9088
91- If the Oracle Client libraries cannot be loaded from ``lib_dir ``, then an
92- exception is raised.
89+ This directory should contain the libraries from an unzipped Instant
90+ Client 'Basic' or 'Basic Light' package. If you pass the library
91+ directory from a full client or database installation, such as Oracle
92+ Database "XE" Express Edition, then you will need to have previously set
93+ your environment to use that same software installation. Otherwise, files
94+ such as message files will not be located and you may have library
95+ version clashes. On Windows, when the path contains backslashes, use a
96+ 'raw' string like ``r"C:\instantclient_19_14" ``.
9397
94- - By calling :meth: ` ~oracledb.init_oracle_client() ` without passing a
95- `` lib_dir `` parameter:
98+ If the Oracle Client libraries cannot be loaded from `` lib_dir ``, then an
99+ exception is raised.
96100
97- .. code-block :: python
101+ - By calling :meth: `~oracledb.init_oracle_client() ` without passing a
102+ ``lib_dir `` parameter:
98103
99- import oracledb
104+ .. code-block :: python
100105
101- oracledb.init_oracle_client()
106+ import oracledb
107+
108+ oracledb.init_oracle_client()
102109
103- In this case, Oracle Client libraries are first looked for in the
104- directory where the python-oracledb binary module is installed. This
105- directory should contain the libraries from an unzipped Instant Client
106- 'Basic' or 'Basic Light' package.
110+ In this case, Oracle Client libraries are first looked for in the
111+ directory where the python-oracledb binary module is installed. This
112+ directory should contain the libraries from an unzipped Instant Client
113+ 'Basic' or 'Basic Light' package.
107114
108- If the libraries are not found there, the search looks at the directories
109- on the system library search path, for example, the ``PATH `` environment
110- variable.
115+ If the libraries are not found there, the search looks at the directories
116+ on the system library search path, for example, the ``PATH `` environment
117+ variable.
111118
112- If the Oracle Client libraries cannot be loaded, then an exception is
113- raised.
119+ If the Oracle Client libraries cannot be loaded, then an exception is
120+ raised.
114121
115122.. _macinit :
116123
117- * On macOS, python-oracledb Thick mode can be enabled as follows:
124+ Setting the Oracle Client Directory on macOS
125+ ++++++++++++++++++++++++++++++++++++++++++++
118126
119- - By passing the ``lib_dir `` parameter in a call to
120- :meth: `~oracledb.init_oracle_client() `, for example:
127+ On macOS, python-oracledb Thick mode can be enabled as follows:
121128
122- .. code-block :: python
129+ - By passing the ``lib_dir `` parameter in a call to
130+ :meth: `~oracledb.init_oracle_client() `, for example:
123131
124- import oracledb
132+ .. code-block :: python
125133
126- oracledb.init_oracle_client( lib_dir = " /Users/your_username/Downloads/instantclient_19_8 " )
134+ import oracledb
127135
128- This directory should contain the libraries from an unzipped Instant
129- Client 'Basic' or 'Basic Light' package. If the Oracle Client libraries
130- cannot be loaded from ``lib_dir ``, then an exception is raised.
136+ oracledb.init_oracle_client(lib_dir = " /Users/your_username/Downloads/instantclient_19_8" )
131137
132- - By calling :meth: `~oracledb.init_oracle_client() ` without passing a
133- ``lib_dir `` parameter:
138+ This directory should contain the libraries from an unzipped Instant
139+ Client 'Basic' or 'Basic Light' package. If the Oracle Client libraries
140+ cannot be loaded from ``lib_dir ``, then an exception is raised.
141+
142+ - By calling :meth: `~oracledb.init_oracle_client() ` without passing a
143+ ``lib_dir `` parameter:
134144
135145 .. code-block :: python
136146
137147 import oracledb
138148
139149 oracledb.init_oracle_client()
140150
141- In this case, the Oracle Client libraries are first looked for in the
142- directory where the python-oracledb Thick mode binary module is installed.
143- This directory should contain the libraries from an unzipped Instant Client
144- 'Basic' or 'Basic Light' package, or a symbolic link to the main Oracle
145- Client library if Instant Client is in a different directory.
146-
147- You can find the directory containing the Thick mode binary module by
148- calling the python CLI without specifying a Python script, executing
149- ``import oracledb ``, and then typing ``oracledb `` at the prompt. For
150- example if
151- ``/Users/yourname/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb ``
152- contains ``thick_impl.cpython-39-darwin.so ``, then you could run ``ln -s
153- ~/Downloads/instantclient_19_8/libclntsh.dylib
154- ~/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb/ ``.
155-
156- If python-oracledb does not find the Oracle Client library in that
157- directory, the directories on the system library search path may be used,
158- for example, ``~/lib/ `` and ``/usr/local/lib ``, or in ``$DYLD_LIBRARY_PATH ``.
159- These paths will vary with macOS version and Python version. Any value
160- in ``DYLD_LIBRARY_PATH `` will not propagate to a sub-shell.
161-
162- If the Oracle Client libraries cannot be loaded, then an exception is
163- raised.
151+ In this case, the Oracle Client libraries are first looked for in the
152+ directory where the python-oracledb Thick mode binary module is installed.
153+ This directory should contain the libraries from an unzipped Instant Client
154+ 'Basic' or 'Basic Light' package, or a symbolic link to the main Oracle
155+ Client library if Instant Client is in a different directory.
156+
157+ You can find the directory containing the Thick mode binary module by
158+ calling the python CLI without specifying a Python script, executing
159+ ``import oracledb ``, and then typing ``oracledb `` at the prompt. For
160+ example if
161+ ``/Users/yourname/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb ``
162+ contains ``thick_impl.cpython-39-darwin.so ``, then you could run ``ln -s
163+ ~/Downloads/instantclient_19_8/libclntsh.dylib
164+ ~/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb/ ``.
165+
166+ If python-oracledb does not find the Oracle Client library in that
167+ directory, the directories on the system library search path may be used,
168+ for example, ``~/lib/ `` and ``/usr/local/lib ``, or in ``$DYLD_LIBRARY_PATH ``.
169+ These paths will vary with macOS version and Python version. Any value
170+ in ``DYLD_LIBRARY_PATH `` will not propagate to a sub-shell.
171+
172+ If the Oracle Client libraries cannot be loaded, then an exception is
173+ raised.
164174
165175.. _linuxinit :
166176
167- * On Linux and related platforms, python-oracledb Thick mode can be enabled as
168- follows:
177+ Setting the Oracle Client Directory on Linux and Related Platforms
178+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
169179
170- - By calling :meth: ` ~ oracledb.init_oracle_client() ` without passing a
171- `` lib_dir `` parameter :
180+ On Linux and related platforms, python- oracledb Thick mode can be enabled as
181+ follows :
172182
173- .. code-block :: python
183+ - By calling :meth: `~oracledb.init_oracle_client() ` without passing a
184+ ``lib_dir `` parameter:
174185
175- import oracledb
186+ .. code-block :: python
176187
177- oracledb.init_oracle_client()
188+ import oracledb
178189
179- Oracle Client libraries are looked for in the operating system library
180- search path, such as configured with ``ldconfig `` or set in the environment
181- variable ``LD_LIBRARY_PATH ``. On some UNIX platforms an OS specific
182- equivalent, such as ``LIBPATH `` or ``SHLIB_PATH `` is used instead of
183- ``LD_LIBRARY_PATH ``.
184-
185- If libraries are not found in the system library search path, then
186- ``$ORACLE_HOME/lib `` will be used. Note that the environment variable
187- ``ORACLE_HOME `` should only ever be set when you have a full database
188- installation or full client installation (such as installed with the Oracle
189- GUI installer). It should not be set if you are using Oracle Instant
190- Client. The ``ORACLE_HOME `` variable, and other necessary variables, should
191- be set before starting Python. See :ref: `envset `.
192-
193- If the Oracle Client libraries cannot be loaded, then an exception is
194- raised.
195-
196- Ensure that the Python process has directory and file access permissions for the
197- Oracle Client libraries. On Linux ensure a ``libclntsh.so `` file exists. On
198- macOS ensure a ``libclntsh.dylib `` file exists. python-oracledb Thick will not directly
199- load ``libclntsh.*.XX.1 `` files in ``lib_dir `` or from the directory where the
200- python-oracledb binary module is available. Note that other libraries used by
201- ``libclntsh* `` are also required.
190+ oracledb.init_oracle_client()
202191
203- To trace the loading of Oracle Client libraries, the environment variable
204- ``DPI_DEBUG_LEVEL `` can be set to 64 before starting Python. For example, on
205- Linux, you might use::
192+ Oracle Client libraries are looked for in the operating system library
193+ search path, such as configured with ``ldconfig `` or set in the environment
194+ variable ``LD_LIBRARY_PATH ``. On some UNIX platforms an OS specific
195+ equivalent, such as ``LIBPATH `` or ``SHLIB_PATH `` is used instead of
196+ ``LD_LIBRARY_PATH ``.
206197
207- $ export DPI_DEBUG_LEVEL=64
208- $ python myapp.py 2> log.txt
198+ If libraries are not found in the system library search path, then
199+ ``$ORACLE_HOME/lib `` will be used. Note that the environment variable
200+ ``ORACLE_HOME `` should only ever be set when you have a full database
201+ installation or full client installation (such as installed with the Oracle
202+ GUI installer). It should not be set if you are using Oracle Instant
203+ Client. The ``ORACLE_HOME `` variable, and other necessary variables, should
204+ be set before starting Python. See :ref: `envset `.
209205
206+ If the Oracle Client libraries cannot be loaded, then an exception is
207+ raised.
208+
209+ Ensure that the Python process has directory and file access permissions for
210+ the Oracle Client libraries. On Linux ensure a ``libclntsh.so `` file exists.
211+ On macOS ensure a ``libclntsh.dylib `` file exists. python-oracledb Thick will
212+ not directly load ``libclntsh.*.XX.1 `` files in ``lib_dir `` or from the directory
213+ where the python-oracledb binary module is available. Note that other libraries
214+ used by ``libclntsh* `` are also required.
210215
211216.. _usinginitoracleclient :
212217
213- Using oracledb.init_oracle_client() to set the Oracle Client directory
214- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
218+ Calling oracledb.init_oracle_client() to Set the Oracle Client Directory
219+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
215220
216221Oracle Client Libraries are loaded when :meth: `oracledb.init_oracle_client() `
217222is called. In some environments, applications can use the ``lib_dir ``
@@ -250,6 +255,16 @@ variable. Otherwise, you will get errors like ``ORA-1804``. You should set thi
250255along with other Oracle environment variables before starting Python as
251256shown in :ref: `envset `.
252257
258+ **Tracing Oracle Client Libraries Loading **
259+
260+ To trace the loading of Oracle Client libraries, the environment variable
261+ ``DPI_DEBUG_LEVEL `` can be set to 64 before starting Python. For example, on
262+ Linux, you might use::
263+
264+ $ export DPI_DEBUG_LEVEL=64
265+ $ python myapp.py 2> log.txt
266+
267+
253268.. _optnetfiles :
254269
255270Optional Oracle Net Configuration Files
0 commit comments