@@ -32,7 +32,7 @@ Specification.
3232cx_Oracle always runs in a Thick mode using Oracle Client libraries. The
3333features in python-oracledb Thick mode and cx_Oracle 8.3 are the same, subject
3434to the :ref: `new features <releasenotes >`, some :ref: `deprecations
35- <deprecations>`, and to other changes noted in this section .
35+ <deprecations>`, and to other changes noted in the documentation .
3636
3737Oracle Client Library Loading Differences from cx_Oracle
3838--------------------------------------------------------
@@ -187,8 +187,9 @@ SessionPool Object Differences
187187The SessionPool object (which is an alias for the :ref: `ConnectionPool object
188188<connpool>`) differences between the python-oracledb and cx_Oracle drivers are:
189189
190- - A Python type() will show the class as ``oracledb.ConnectionPool `` instead
191- of ``cx_Oracle.SessionPool ``.
190+ - A Python `type() <https://docs.python.org/3/library/functions.html#type >`__
191+ will show the class as ``oracledb.ConnectionPool `` instead of
192+ ``cx_Oracle.SessionPool ``.
192193
193194- A new boolean attribute, ``SessionPool.thin `` (see
194195 :attr: `ConnectionPool.thin `) is available. This attribute is *True * if the
@@ -374,33 +375,46 @@ Example error messages are:
374375Upgrading from cx_Oracle 8.3 to python-oracledb
375376===============================================
376377
377- This section provides the detailed steps needed to upgrade from the obsolete
378- cx_Oracle driver to python-oracledb.
379-
380378Things to Know Before the Upgrade
381379---------------------------------
382380
383381Below is a list of some useful things to know before upgrading from cx_Oracle
384382to python-oracledb:
385383
386384- You can have both cx_Oracle and python-oracledb installed, and can use both
387- in the same application.
385+ in the same application. Install python-oracledb like::
386+
387+ python -m pip install oracledb --upgrade
388+
389+ See :ref: `installation ` for details.
390+
391+ - By default, python-oracledb runs in a 'Thin' mode which connects directly to
392+ Oracle Database. This mode does not need Oracle Client libraries to be
393+ installed. However, some additional functionality is available when
394+ python-oracledb uses them. Python-oracledb is said to be in 'Thick' mode
395+ when Oracle Client libraries are used. The Thick mode is equivalent to
396+ cx_Oracle.
388397
389- - If you only want to use the python-oracledb driver in Thin mode, then you do
390- not need Oracle Client libraries such as from Oracle Instant Client. You
391- only need to :ref: `install <installation >` the driver itself::
398+ - python-oracledb Thin and Thick modes have the same level of support for the
399+ `Python Database API specification <https://peps.python.org/pep-0249/ >`_ and
400+ can be used to connect to on-premises databases and Oracle Cloud
401+ databases. See :ref: `driverdiff `.
392402
393- python -m pip install oracledb
403+ Examples can be found in the `GitHub samples directory
404+ <https://github.com/oracle/python-oracledb/tree/main/samples> `__. A basic
405+ example is:
394406
395- See :ref: `driverdiff `.
407+ .. code-block :: python
408+
409+ import oracledb
410+ import getpass
396411
397- - python-oracledb Thin and Thick modes have the same level of support for
398- the `Python Database API specification <https://peps.python.org/pep-0249/ >`_
399- and can be used to connect to on-premises databases and Oracle Cloud
400- databases. However, python-oracledb Thin mode does not support some
401- advanced Oracle Database features such as Application Continuity (AC),
402- Continuous Query Notification (CQN), and Sharding. See :ref: `Features
403- Supported <featuresummary>` for details.
412+ pw = getpass.getpass(f " Enter password for hr@localhost/orclpdb: " )
413+
414+ with oracledb.connect(user = " hr" , password = userpwd, dsn = " localhost/orclpdb" ) as connection:
415+ with connection.cursor() as cursor:
416+ for r in cursor.execute(" select sysdate from dual" ):
417+ print (r)
404418
405419 - python-oracledb can be used in SQLAlchemy, Django, Pandas, Superset and other
406420 frameworks and Object-relational Mappers (ORMs). To use python-oracledb in
@@ -414,17 +428,19 @@ to python-oracledb:
414428
415429 .. code-block :: python
416430
417- oracledb.connect(user = " scott" , password = pw, dsn = " localhost/orclpdb" )
431+ connection = oracledb.connect(user = " scott" , password = pw, dsn = " localhost/orclpdb" )
418432
419433 This no longer works:
420434
421435 .. code-block :: python
422436
423- oracledb.connect(" scott" , pw, " localhost/orclpdb" )
437+ connection = oracledb.connect(" scott" , pw, " localhost/orclpdb" )
424438
425439 - Some previously deprecated features are no longer available. See
426440 :ref: `deprecations `.
427441
442+ - There are many new features, see the :ref: `release notes <releasenotes >`.
443+
428444.. _commonupgrade :
429445
430446Steps to Upgrade to python-oracledb
@@ -577,8 +593,8 @@ following steps:
577593Additional Upgrade Steps to use python-oracledb Thin Mode
578594+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
579595
580- To use python-oracledb Thin mode, the following changes need to be made in
581- addition to the common :ref: `commonupgrade `:
596+ To upgrade from cx_Oracle to python-oracledb Thin mode, the following changes
597+ need to be made in addition to the common :ref: `commonupgrade `:
582598
5835991. Remove calls to :func: `~oracledb.init_oracle_client ` since this turns on
584600 python-oracledb Thick mode.
@@ -635,7 +651,7 @@ addition to the common :ref:`commonupgrade`:
635651 :ref: `oraaccess.xml <optclientfiles >` files. The Thin mode lets equivalent
636652 properties be set in the application when connecting.
637653
638- 6. To use python-oracledb Thin mode in an ORACLE_HOME database installation
654+ 6. To use python-oracledb Thin mode in an `` ORACLE_HOME `` database installation
639655 environment, you must use an explicit connection string since the
640656 ``ORACLE_SID ``, ``TWO_TASK ``, and ``LOCAL `` environment variables are not
641657 used. They are used in Thick mode.
@@ -664,8 +680,8 @@ addition to the common :ref:`commonupgrade`:
664680Additional Upgrade Steps to use python-oracledb Thick Mode
665681++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
666682
667- To use python-oracledb Thick mode, the following changes need to be made in
668- addition to the common :ref: `commonupgrade `:
683+ To upgrade from cx_Oracle to python-oracledb Thick mode, the following changes
684+ need to be made in addition to the common :ref: `commonupgrade `:
669685
6706861. The function :func: `oracledb.init_oracle_client() ` *must * be called to
671687 enable python-oracle Thick mode. It can be called anywhere before the first
0 commit comments