Skip to content

Commit 7e8b89c

Browse files
Small doc updates.
1 parent 54c638a commit 7e8b89c

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

doc/src/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ Welcome to python-oracledb's documentation
22
==========================================
33

44
The python-oracledb driver is an open source Python module that enables access
5-
to Oracle Database. Python-oracledb is the new name for the cx_Oracle driver.
5+
to Oracle Database. Python-oracledb is the renamed, major version successor to
6+
cx_Oracle 8.3. The cx_Oracle driver is obsolete and should not be used for new
7+
development.
68

79
You can use assistive technology products, such as screen readers, while you
810
work with the python-oracledb documentation. You can also use the keyboard

doc/src/user_guide/appendix_a.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Oracle Database. This mode does not need Oracle Client libraries. However,
99
some additional functionality is available when python-oracledb uses them.
1010
Python-oracledb is said to be in 'Thick' mode when Oracle Client libraries are
1111
used. Both modes have comprehensive functionality supporting the Python
12-
Database API v2.0 Specification. See :ref:`initialization` for how to enable
13-
Thick mode.
12+
Database API v2.0 Specification `PEP 249
13+
<https://peps.python.org/pep-0249/>`__. See :ref:`initialization` for how to
14+
enable Thick mode.
1415

1516
The following table summarizes the Oracle Database features supported by
1617
python-oracledb Thin and Thick modes, and by cx_Oracle 8.3. For more details
@@ -26,10 +27,6 @@ see :ref:`driverdiff` and :ref:`compatibility`.
2627
- python-oracledb Thin Mode
2728
- python-oracledb Thick Mode
2829
- cx_Oracle 8.3
29-
* - Python Database API Support (see `PEP 249 <https://peps.python.org/pep-0249/>`__)
30-
- Yes - a couple of features are not feasible. Many extensions.
31-
- Yes - a couple of features are not feasible. Many extensions.
32-
- Yes - a couple of features are not feasible. Many extensions.
3330
* - Oracle Client version
3431
- Not applicable
3532
- Release 11.2 and later

doc/src/user_guide/appendix_c.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Appendix C: The python-oracledb and cx_Oracle Drivers
77
The python-oracledb driver is the renamed, major version successor to cx_Oracle
88
8.3. As a major release, the python-oracledb driver has :ref:`new features
99
<releasenotes>` and some :ref:`deprecations`. Also see :ref:`upgrading83`.
10+
The cx_Oracle driver is obsolete and should not be used for new development.
1011

1112
.. _compatibility:
1213

doc/src/user_guide/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Installing python-oracledb
77
The python-oracledb driver allows Python 3 applications to connect to Oracle
88
Database.
99

10-
Python-oracledb is the new name for the Python `cx_Oracle driver
11-
<https://oracle.github.io/python-cx_Oracle/>`__. If you are upgrading from
12-
cx_Oracle, see :ref:`upgrading83`.
10+
The python-oracledb driver is the renamed, major version successor to cx_Oracle
11+
8.3. For upgrade information, see :ref:`upgrading83`. The cx_Oracle driver is
12+
obsolete and should not be used for new development.
1313

1414
.. figure:: /images/python-oracledb-thin-arch.png
1515
:alt: architecture of the python-oracledb driver

doc/src/user_guide/introduction.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Changes in python-oracledb
2626
releases can be found in the :ref:`release notes <releasenotes>`.
2727

2828
The python-oracledb driver is the renamed, major version successor to cx_Oracle
29-
8.3. For upgrade information, see :ref:`upgrading83`.
29+
8.3. For upgrade information, see :ref:`upgrading83`. The cx_Oracle driver is
30+
obsolete and should not be used for new development.
3031

3132
Getting Started
3233
===============

doc/src/user_guide/sql_execution.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ To extract the column names from a query you can use code like:
180180
181181
with connection.cursor() as cursor:
182182
cursor.execute("select * from locations")
183-
columns = [col[0] for col in cursor.description]
183+
columns = [col.name for col in cursor.description]
184184
print(columns)
185185
for r in cursor:
186186
print(r)
@@ -192,6 +192,22 @@ This will print::
192192
(1100, '93091 Calle della Testa', '10934', 'Venice', None, 'IT')
193193
. . .
194194

195+
**Changing Column Names to Lowercase**
196+
197+
To change all column names to lowercase you could do:
198+
199+
.. code-block:: python
200+
201+
cursor.execute("select * from locations where location_id = 1000")
202+
203+
columns = [col.name.lower() for col in cursor.description]
204+
print(columns)
205+
206+
The output is::
207+
208+
['location_id', 'street_address', 'postal_code', 'city', 'state_province',
209+
'country_id']
210+
195211
.. _defaultfetchtypes:
196212

197213
Fetch Data Types
@@ -452,13 +468,15 @@ the database. The :meth:`Cursor.rowfactory` method is called with the tuple
452468
fetched from the database before it is returned to the application. The method
453469
can convert the tuple to a different value.
454470

471+
**Fetching Rows as Dictionaries**
472+
455473
For example, to fetch each row of a query as a dictionary:
456474

457475
.. code-block:: python
458476
459477
cursor.execute("select * from locations where location_id = 1000")
460478
461-
columns = [col[0] for col in cursor.description]
479+
columns = [col.name for col in cursor.description]
462480
cursor.rowfactory = lambda *args: dict(zip(columns, args))
463481
data = cursor.fetchone()
464482
print(data)
@@ -484,8 +502,11 @@ only one of the similarly named columns will be included in the dictionary:
484502
dogs.color
485503
from cats, dogs
486504
505+
**Example with an Output Type Handler, Outconverter, and Row Factory**
506+
487507
An example showing an :ref:`output type handler <outputtypehandlers>`, an
488-
:ref:`outconverter <outconverters>`, and a row factory is:
508+
:ref:`outconverter <outconverters>`, and a :ref:`row factory <rowfactories>`
509+
is:
489510

490511
.. code-block:: python
491512
@@ -505,17 +526,17 @@ An example showing an :ref:`output type handler <outputtypehandlers>`, an
505526
506527
cursor.execute("select 123 as col1, 'abc' as col2 from dual")
507528
508-
columns = [col[0] for col in cursor.description]
529+
columns = [col.name.lower() for col in cursor.description]
509530
cursor.rowfactory = lambda *args: dict(zip(columns, args))
510531
for r in cursor.fetchall():
511532
print(r)
512533
513534
The database converts the number to a string before it is returned to
514-
python-oracledb. The outconverter appends "was a string" to this value.
515-
Finally the row factory changes the complete row to a dictionary. The output
516-
is::
535+
python-oracledb. The outconverter appends "was a string" to this value. The
536+
column names are converted to lowercase. Finally, the row factory changes the
537+
complete row to a dictionary. The output is::
517538

518-
{'COL1': '123 was a string', 'COL2': 'abc'}
539+
{'col1': '123 was a string', 'col2': 'abc'}
519540

520541
.. _numberprecision:
521542

0 commit comments

Comments
 (0)