Skip to content

Commit 631b872

Browse files
Documentation improvements.
1 parent 3a94168 commit 631b872

File tree

3 files changed

+105
-78
lines changed

3 files changed

+105
-78
lines changed

doc/src/user_guide/bind.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,14 +739,14 @@ Binding Column and Table Names
739739
==============================
740740

741741
Column and table names cannot be bound in SQL queries. You can concatenate
742-
text to build up a SQL statement, but make sure you use a white-list or other
742+
text to build up a SQL statement, but make sure you use an Allow List or other
743743
means to validate the data in order to avoid SQL Injection security issues:
744744

745745
.. code-block:: python
746746
747-
tableWhiteList = ['employees', 'departments']
747+
tableAllowList = ['employees', 'departments']
748748
tableName = getTableName() # get the table name from user input
749-
if tableName not in tableWhiteList:
749+
if tableName not in tableAllowList:
750750
raise Exception('Invalid table name')
751751
sql = 'select * from ' + tableName
752752

doc/src/user_guide/initialization.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,21 @@ cx_Oracle looks for the Oracle Client libraries as follows:
6060
``lib_dir``, then an exception is raised.
6161

6262
- If ``lib_dir`` was not specified, then Oracle Client libraries are looked
63-
for in the directory where the cx_Oracle binary module is. This
64-
directory should contain the libraries from an unzipped Instant Client
65-
'Basic' or 'Basic Light' package. If the libraries are not found, no
66-
exception is raised and the search continues, see next bullet point.
63+
for in the directory where the cx_Oracle binary module is. This directory
64+
should contain the libraries from an unzipped Instant Client 'Basic' or
65+
'Basic Light' package. For example if
66+
``/Users/your_username/Library/Python/3.8/lib/python/site-packages``
67+
contains ``cx_Oracle.cpython-38-darwin.so``, then you could run ``ln -s
68+
~/instantclient_19_3/libclntsh.dylib
69+
~/Library/Python/3.8/lib/python/site-packages``. If the libraries are not
70+
found, no exception is raised and the search continues, see next bullet
71+
point.
6772

6873
- In the directories on the system library search path, e.g. ``~/lib/`` and
69-
``/usr/lib``. If the Oracle Client libraries cannot be loaded, then an
70-
exception is raised.
74+
``/usr/local/lib``, or in ``$DYLD_LIBRARY_PATH``. These paths will vary
75+
with macOS version and Python version. Any value in
76+
``DYLD_LIBRARY_PATH`` will not propagate to a sub-shell. If the Oracle
77+
Client libraries cannot be loaded, then an exception is raised.
7178

7279
* On Linux and related platforms:
7380

doc/src/user_guide/installation.rst

Lines changed: 89 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ Quick Start cx_Oracle Installation
3737
==================================
3838

3939
- Install `Python <https://www.python.org/downloads>`__ 3, if not already
40-
available. Python 3.5 and higher are supported by cx_Oracle 8.
40+
available. On macOS you must always install your own Python.
41+
42+
Python 3.5 and higher are supported by cx_Oracle 8. For Python 2, use
43+
cx_Oracle 7.3.
4144

4245
- Install cx_Oracle from `PyPI
4346
<https://pypi.org/project/cx-Oracle/>`__ with:
@@ -50,18 +53,21 @@ Quick Start cx_Oracle Installation
5053
the source package will be downloaded instead. This will be compiled
5154
and the resulting binary installed.
5255

53-
If you are behind a proxy, specify your proxy server:
56+
The ``--user`` option may be useful, if you don't have permission to write to
57+
system directories:
5458

5559
.. code-block:: shell
5660
57-
python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
61+
python -m pip install cx_Oracle --upgrade --user
62+
63+
If you are behind a proxy, add a proxy server to the command, for example add
64+
``--proxy=http://proxy.example.com:80``
5865

5966
- Add Oracle 19, 18, 12 or 11.2 client libraries to your operating system
6067
library search path such as ``PATH`` on Windows or ``LD_LIBRARY_PATH`` on
61-
Linux. On macOS move the files to ``~/lib`` or ``/usr/local/lib``.
62-
Alternatively, on macOS and Windows, you may prefer to use
63-
:meth:`~cx_Oracle.init_oracle_client()` in your application to pass the Oracle
64-
Client directory name, see :ref:`libinit`.
68+
Linux. On macOS use :meth:`~cx_Oracle.init_oracle_client()` in your
69+
application to pass the Oracle Client directory name, see :ref:`libinit`.
70+
This is also usable on Windows.
6571

6672
To get the libraries:
6773

@@ -202,18 +208,22 @@ install cx_Oracle from `PyPI
202208
203209
python -m pip install cx_Oracle --upgrade
204210
205-
If you are behind a proxy, specify your proxy server:
211+
The ``--user`` option may be useful, if you don't have permission to write to
212+
system directories:
206213

207214
.. code-block:: shell
208215
209-
python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
216+
python -m pip install cx_Oracle --upgrade --user
217+
218+
If you are behind a proxy, add a proxy server to the command, for example add
219+
``--proxy=http://proxy.example.com:80``
210220

211221
This will download and install a pre-compiled binary `if one is
212222
available <https://pypi.org/project/cx-Oracle/>`__ for your
213223
architecture. If a pre-compiled binary is not available, the source
214224
will be downloaded, compiled, and the resulting binary installed.
215225
Compiling cx_Oracle requires the ``Python.h`` header file. If you are
216-
using the default python package, this file is in the ``python-devel``
226+
using the default ``python`` package, this file is in the ``python-devel``
217227
package or equivalent.
218228

219229
Install Oracle Client
@@ -291,7 +301,7 @@ To use cx_Oracle with Oracle Instant Client zip files:
291301
.. code-block:: python
292302
293303
import cx_Oracle
294-
cx_Oracle.init_oracle_client(config_dir = "/home/your_username/oracle/your_config_dir")
304+
cx_Oracle.init_oracle_client(config_dir="/home/your_username/oracle/your_config_dir")
295305
296306
Or set the environment variable ``TNS_ADMIN`` to that directory name.
297307

@@ -358,7 +368,7 @@ To use cx_Oracle with Oracle Instant Client RPMs:
358368
.. code-block:: python
359369
360370
import cx_Oracle
361-
cx_Oracle.init_oracle_client(config_dir = "/opt/oracle/your_config_dir")
371+
cx_Oracle.init_oracle_client(config_dir="/opt/oracle/your_config_dir")
362372
363373
Or set the environment variable ``TNS_ADMIN`` to that directory name.
364374

@@ -481,26 +491,26 @@ To use cx_Oracle with Oracle Instant Client zip files:
481491
3. There are several alternative ways to tell cx_Oracle where your Oracle Client
482492
libraries are, see :ref:`initialization`.
483493

484-
With Oracle Instant Client you can use :meth:`~cx_Oracle.init_oracle_client()`
485-
in your application:
494+
* With Oracle Instant Client you can use :meth:`~cx_Oracle.init_oracle_client()`
495+
in your application, for example:
486496

487-
.. code-block:: python
497+
.. code-block:: python
488498
489-
import cx_Oracle
490-
cx_Oracle.init_oracle_client(lib_dir = "C:\oracle\instantclient_19_6")
499+
import cx_Oracle
500+
cx_Oracle.init_oracle_client(lib_dir=r"C:\oracle\instantclient_19_6")
491501
492-
Alternatively, add the Oracle Client directory to the ``PATH`` environment
493-
variable. The Instant Client directory must occur in ``PATH`` before any
494-
other Oracle directories. Restart any open command prompt windows.
502+
* Alternatively, add the Oracle Instant Client directory to the ``PATH``
503+
environment variable. The directory must occur in ``PATH`` before any
504+
other Oracle directories. Restart any open command prompt windows.
495505

496-
Another way to set ``PATH`` is to use a batch file that sets it before Python
497-
is executed, for example::
506+
* Another way to set ``PATH`` is to use a batch file that sets it before Python
507+
is executed, for example::
498508

499-
REM mypy.bat
500-
SET PATH=C:\oracle\instantclient_19_6;%PATH%
501-
python %*
509+
REM mypy.bat
510+
SET PATH=C:\oracle\instantclient_19_6;%PATH%
511+
python %*
502512

503-
Invoke this batch file every time you want to run Python.
513+
Invoke this batch file every time you want to run Python.
504514

505515
4. Oracle Instant Client libraries require a Visual Studio redistributable with
506516
a 64-bit or 32-bit architecture to match Instant Client's architecture.
@@ -519,7 +529,7 @@ To use cx_Oracle with Oracle Instant Client zip files:
519529
.. code-block:: python
520530
521531
import cx_Oracle
522-
cx_Oracle.init_oracle_client(config_dir = "C:\oracle\your_config_dir")
532+
cx_Oracle.init_oracle_client(config_dir=r"C:\oracle\your_config_dir")
523533
524534
Or set the environment variable ``TNS_ADMIN`` to that directory name.
525535

@@ -550,21 +560,23 @@ Python architecture.
550560
``network\admin`` subdirectory of the Oracle Database software
551561
installation.
552562

553-
Alternatively, use :meth:`~cx_Oracle.init_oracle_client()` or set
554-
``TNS_ADMIN`` as shown in the previous section.
563+
Alternatively, pass ``config_dir`` to :meth:`~cx_Oracle.init_oracle_client()`
564+
as shown in the previous section, or set ``TNS_ADMIN`` to the directory name.
555565

556566
Installing cx_Oracle on macOS
557567
=============================
558568

559569
Install Python
560570
--------------
561571

562-
Make sure you are not using the bundled Python. This has restricted
563-
entitlements and will fail to load Oracle client libraries. Instead
564-
use `Homebrew <https://brew.sh>`__ or `Python.org
572+
Make sure you are not using a bundled Python. These have restricted
573+
entitlements and will fail to load Oracle client libraries. Instead use
574+
`Homebrew <https://brew.sh>`__ or `Python.org
565575
<https://www.python.org/downloads>`__.
566576

567577
Note Instant Client 19 and earlier are not supported on macOS 10.15 Catalina.
578+
You will need to allow access to several Instant Client libraries from the
579+
Security & Privacy preference pane.
568580

569581
Install cx_Oracle
570582
-----------------
@@ -575,19 +587,19 @@ package to install cx_Oracle from `PyPI
575587

576588
python -m pip install cx_Oracle --upgrade
577589

578-
If you are behind a proxy, specify your proxy server:
590+
The ``--user`` option may be useful, if you don't have permission to write to
591+
system directories:
579592

580593
.. code-block:: shell
581594
582-
python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
595+
python -m pip install cx_Oracle --upgrade --user
583596
584-
The ``--user`` option may also be useful, if you don't have permission to write
585-
to ``/usr``.
597+
If you are behind a proxy, add a proxy server to the command, for example add
598+
``--proxy=http://proxy.example.com:80``
586599

587600
The source will be downloaded, compiled, and the resulting binary
588601
installed.
589602

590-
591603
Install Oracle Instant Client
592604
-----------------------------
593605

@@ -615,64 +627,72 @@ To use cx_Oracle with Oracle Instant Client zip files:
615627
616628
This will create a directory ``/Users/your_username/instantclient_19_3``.
617629

618-
3. There are several alternative ways to tell cx_Oracle where your Oracle Client
619-
libraries are, see :ref:`initialization`.
630+
3. There are several alternative ways to tell cx_Oracle where your Oracle
631+
Instant Client libraries are, see :ref:`initialization`.
620632

621-
You can use :meth:`~cx_Oracle.init_oracle_client()` in your
622-
application:
633+
* You can use :meth:`~cx_Oracle.init_oracle_client()` in your
634+
application:
623635

624-
.. code-block:: python
625-
626-
import cx_Oracle
627-
cx_Oracle.init_oracle_client(lib_dir = "/Users/your_username/instantclient_19_3")
636+
.. code-block:: python
628637
638+
import cx_Oracle
639+
cx_Oracle.init_oracle_client(lib_dir="/Users/your_username/instantclient_19_3")
629640
630-
Alternatively, add a link to ``$HOME/lib`` or ``/usr/local/lib`` to enable
631-
applications to find Instant Client. If the ``lib`` sub-directory does not
632-
exist, you can create it. For example:
633-
634-
.. code-block:: shell
641+
* Alternatively, locate the directory with the cx_Oracle module binary and
642+
link or copy Oracle Instant Client to that directory. For example, if you
643+
installed cx_Oracle with ``--user`` in Python 3.8, then
644+
``cx_Oracle.cpython-38-darwin.so`` might be in
645+
``~/Library/Python/3.8/lib/python/site-packages``. You can then run
646+
``ln -s ~/instantclient_19_3/libclntsh.dylib
647+
~/Library/Python/3.8/lib/python/site-packages`` or copy the Instant Client
648+
libraries to that directory.
635649

636-
mkdir ~/lib
637-
ln -s ~/instantclient_19_3/libclntsh.dylib ~/lib/
650+
* Alternatively, you can set ``DYLD_LIBRARY_PATH`` to the directory
651+
containing Oracle Instant Client, however this needs to be set in each
652+
terminal or process that invokes Python. The variable will not propagate
653+
to sub-shells.
638654

639-
If you now run ``ls -l ~/lib/libclntsh.dylib`` you will see something like:
655+
* Alternatively, on older versions of macOS, you could add a link to
656+
``$HOME/lib`` or ``/usr/local/lib`` to enable applications to find Instant
657+
Client. If the ``lib`` sub-directory does not exist, you can create
658+
it. For example:
640659

641-
.. code-block:: text
660+
.. code-block:: shell
642661
643-
lrwxr-xr-x 1 your_username staff 48 12 Nov 15:04 /Users/your_username/lib/libclntsh.dylib -> /Users/your_username/instantclient_19_3/libclntsh.dylib
662+
mkdir ~/lib
663+
ln -s ~/instantclient_19_3/libclntsh.dylib ~/lib/
644664
645-
Instead of linking, you can copy the required OCI libraries. For example:
665+
Instead of linking, you can copy the required OCI libraries. For example:
646666

647-
.. code-block:: shell
667+
.. code-block:: shell
648668
649-
mkdir ~/lib
650-
cp ~/instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} ~/lib/
669+
mkdir ~/lib
670+
cp ~/instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} ~/lib/
651671
652-
For Instant Client 11.2, the OCI libraries must be copied. For example:
672+
For Instant Client 11.2, the OCI libraries must be copied. For example:
653673

654-
.. code-block:: shell
674+
.. code-block:: shell
655675
656-
mkdir ~/lib
657-
cp ~/instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~/lib/
676+
mkdir ~/lib
677+
cp ~/instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~/lib/
658678
659679
4. If you use optional Oracle configuration files such as ``tnsnames.ora``,
660-
``sqlnet.ora`` or ``oraaccess.xml`` with Instant Client, then put the files
661-
in an accessible directory, for example in
680+
``sqlnet.ora`` or ``oraaccess.xml`` with Oracle Instant Client, then put the
681+
files in an accessible directory, for example in
662682
``/Users/your_username/oracle/your_config_dir``. Then use:
663683

664684
.. code-block:: python
665685
666686
import cx_Oracle
667-
cx_Oracle.init_oracle_client(config_dir = "/Users/your_username/oracle/your_config_dir")
687+
cx_Oracle.init_oracle_client(config_dir="/Users/your_username/oracle/your_config_dir")
668688
669689
Or set the environment variable ``TNS_ADMIN`` to that directory name.
670690

671-
Alternatively, put the files in the ``network/admin`` subdirectory of
691+
Alternatively, put the files in the ``network/admin`` subdirectory of Oracle
672692
Instant Client, for example in
673693
``/Users/your_username/instantclient_19_3/network/admin``. This is the
674-
default Oracle configuration directory for executables linked with
675-
this Instant Client.
694+
default Oracle configuration directory for executables linked with this
695+
Instant Client.
676696

677697
Installing cx_Oracle without Internet Access
678698
============================================

0 commit comments

Comments
 (0)