Skip to content

Commit 440163e

Browse files
Improved samples and test suite.
1 parent c665d2e commit 440163e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+426
-240
lines changed

doc/src/release_notes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Version 8.3 (TBD)
1717
implicit conversion to integer has become an error in Python 3.10) and
1818
values that are not `int`, `float` or `decimal.Decimal` are explicitly
1919
rejected.
20+
#) Improved samples and test suite.
2021

2122

2223
Version 8.2.1 (June 2021)

samples/bulk_aq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#------------------------------------------------------------------------------
1111
# bulk_aq.py
1212
# This script demonstrates how to use bulk enqueuing and dequeuing of
13-
# messages with advanced queuing using cx_Oracle. It makes use of a RAW queue
14-
# created in the sample setup.
13+
# messages with advanced queuing. It makes use of a RAW queue created in the
14+
# sample setup.
1515
#
1616
# This script requires cx_Oracle 8.2 and higher.
1717
#------------------------------------------------------------------------------

samples/connection_pool.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#------------------------------------------------------------------------------
66
# connection_pool.py
7-
# This script demonstrates the use of connection pooling in cx_Oracle. Pools
8-
# can significantly reduce connection times for long running applications that
7+
# This script demonstrates the use of connection pooling. Pools can
8+
# significantly reduce connection times for long running applications that
99
# repeatedly open and close connections. Internal features help protect against
1010
# dead connections, and also aid use of Oracle Database features such as FAN
1111
# and Application Continuity.
@@ -27,8 +27,8 @@
2727
# Create a Connection Pool
2828
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
2929
password=sample_env.get_main_password(),
30-
dsn=sample_env.get_connect_string(), min=2,
31-
max=5, increment=1)
30+
dsn=sample_env.get_connect_string(), min=2, max=5,
31+
increment=1)
3232

3333
def the_long_query():
3434
with pool.acquire() as conn:

samples/cqn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This script demonstrates using continuous query notification in Python, a
1313
# feature that is available in Oracle 11g and later. Once this script is
1414
# running, use another session to insert, update or delete rows from the table
15-
# cx_Oracle.TestTempTable and you will see the notification of that change.
15+
# TestTempTable and you will see the notification of that change.
1616
#
1717
# This script requires cx_Oracle 5.3 and higher.
1818
#------------------------------------------------------------------------------

samples/database_change_notification.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This script demonstrates using database change notification in Python, a
1313
# feature that is available in Oracle 10g Release 2. Once this script is
1414
# running, use another session to insert, update or delete rows from the table
15-
# cx_Oracle.TestTempTable and you will see the notification of that change.
15+
# TestTempTable and you will see the notification of that change.
1616
#
1717
# This script requires cx_Oracle 5.3 and higher.
1818
#------------------------------------------------------------------------------

samples/generic_row_factory.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#------------------------------------------------------------------------------
1111

1212
import collections
13+
1314
import cx_Oracle as oracledb
1415
import sample_env
1516

@@ -21,7 +22,7 @@ def cursor(self):
2122

2223
class Cursor(oracledb.Cursor):
2324

24-
def execute(self, statement, args = None):
25+
def execute(self, statement, args=None):
2526
prepare_needed = (self.statement != statement)
2627
result = super().execute(statement, args or [])
2728
if prepare_needed:

samples/json_blob.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
#
1616
#------------------------------------------------------------------------------
1717

18-
import sys
1918
import json
19+
import sys
20+
2021
import cx_Oracle as oracledb
2122
import sample_env
2223

samples/json_direct.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
# For JSON with older databases see json_blob.py
1111
#------------------------------------------------------------------------------
1212

13-
import sys
1413
import json
14+
import sys
15+
1516
import cx_Oracle as oracledb
1617
import sample_env
1718

samples/multi_consumer_aq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#------------------------------------------------------------------------------
1111
# multi_consumer_aq.py
12-
# This script demonstrates how to use multi-consumer advanced queuing using
13-
# cx_Oracle. It makes use of a RAW queue created in the sample setup.
12+
# This script demonstrates how to use multi-consumer advanced queuing. It
13+
# makes use of a RAW queue created in the sample setup.
1414
#
1515
# This script requires cx_Oracle 8.2 and higher.
1616
#------------------------------------------------------------------------------

samples/object_aq.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
#------------------------------------------------------------------------------
1111
# object_aq.py
12-
# This script demonstrates how to use advanced queuing with objects using
13-
# cx_Oracle. It makes use of a simple type and queue created in the sample
14-
# setup.
12+
# This script demonstrates how to use advanced queuing with objects. It makes
13+
# use of a simple type and queue created in the sample setup.
1514
#
1615
# This script requires cx_Oracle 8.2 and higher.
1716
#------------------------------------------------------------------------------

samples/plsql_record.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#
88
# Demonstrate how to bind (in and out) a PL/SQL record.
99
#
10-
# This feature is new in cx_Oracle 5.3 and is only available in Oracle
11-
# Database 12.1 and higher.
10+
# This feature is only available in Oracle Database 12.1 and higher.
1211
#------------------------------------------------------------------------------
1312

1413
import datetime

samples/raw_aq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#------------------------------------------------------------------------------
1111
# raw_aq.py
12-
# This script demonstrates how to use advanced queuing with RAW data using
13-
# cx_Oracle. It makes use of a RAW queue created in the sample setup.
12+
# This script demonstrates how to use advanced queuing with RAW data. It
13+
# makes use of a RAW queue created in the sample setup.
1414
#
1515
# This script requires cx_Oracle 8.2 and higher.
1616
#------------------------------------------------------------------------------

samples/ref_cursor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#------------------------------------------------------------------------------
66
# ref_cursor.py
7-
# Demonstrates the use of REF cursors with cx_Oracle.
7+
# Demonstrates the use of REF cursors.
88
#------------------------------------------------------------------------------
99

1010
import cx_Oracle as oracledb

samples/sample_env.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------
6-
# Sets the environment used by most Python cx_Oracle samples. Production
7-
# applications should consider using External Authentication to
8-
# avoid hard coded credentials.
6+
# Sets the environment used by the sample scripts. Production applications
7+
# should consider using External Authentication to avoid hard coded
8+
# credentials.
99
#
1010
# You can set values in environment variables to bypass the sample requesting
1111
# the information it requires.
@@ -24,8 +24,8 @@
2424
# Net Service Name from a tnsnames.ora file or external naming service,
2525
# or it can be the name of a local Oracle database instance.
2626
#
27-
# If cx_Oracle is using Instant Client, then an Easy Connect string is
28-
# generally appropriate. The syntax is:
27+
# If using Instant Client, then an Easy Connect string is generally
28+
# appropriate. The syntax is:
2929
#
3030
# [//]host_name[:port][/service_name][:server_type][/instance_name]
3131
#

samples/session_callback_plsql.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
pool = oracledb.SessionPool(user=sample_env.get_main_user(),
3030
password=sample_env.get_main_password(),
3131
dsn=sample_env.get_connect_string(), min=2, max=5,
32-
increment=1, session_callback="pkg_SessionCallback.TheCallback")
32+
increment=1,
33+
session_callback="pkg_SessionCallback.TheCallback")
3334

3435
# truncate table logging calls to PL/SQL session callback
3536
with pool.acquire() as conn:

samples/setup_samples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# setup_samples.py
77
#
88
# Creates users and populates their schemas with the tables and packages
9-
# necessary for the cx_Oracle samples. An edition is also created for the
9+
# necessary for running the sample scripts. An edition is also created for the
1010
# demonstration of PL/SQL editioning.
1111
#------------------------------------------------------------------------------
1212

samples/sql/setup_samples_exec.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/*-----------------------------------------------------------------------------
66
* setup_samples_exec.sql
77
* This script performs the actual work of creating and populating the
8-
* schemas with the database objects used by the cx_Oracle samples. An edition
8+
* schemas with the database objects used by the sample scripts. An edition
99
* is also created for the demonstration of PL/SQL editioning. It is called by
1010
* the setup_samples.sql file after acquiring the necessary parameters and also
1111
* by the Python script setup_samples.py.

samples/subclassing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#------------------------------------------------------------------------------
66
# subclassing.py
77
#
8-
# Demonstrate how to subclass cx_Oracle connections and cursors in order to
9-
# add additional functionality (like logging) or create specialized interfaces
10-
# for paticular applications.
8+
# Demonstrate how to subclass connections and cursors in order to add
9+
# additional functionality (like logging) or create specialized interfaces for
10+
# paticular applications.
1111
#------------------------------------------------------------------------------
1212

1313
import cx_Oracle as oracledb

test/drop_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------
66
# drop_test.py
77
#
8-
# Drops the database objects used for the cx_Oracle test suite.
8+
# Drops the database objects used by the test suite.
99
#------------------------------------------------------------------------------
1010

11-
import cx_Oracle
11+
import cx_Oracle as oracledb
1212
import test_env
1313

1414
def drop_tests(conn):
@@ -18,6 +18,6 @@ def drop_tests(conn):
1818
proxy_user=test_env.get_proxy_user())
1919

2020
if __name__ == "__main__":
21-
conn = cx_Oracle.connect(test_env.get_admin_connect_string())
21+
conn = oracledb.connect(test_env.get_admin_connect_string())
2222
drop_tests(conn)
2323
print("Done.")

test/setup_test.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
# setup_test.py
77
#
88
# Creates users and populates their schemas with the tables and packages
9-
# necessary for the cx_Oracle test suite.
9+
# necessary for the test suite.
1010
#------------------------------------------------------------------------------
1111

12-
import cx_Oracle
13-
14-
import test_env
12+
import cx_Oracle as oracledb
1513
import drop_test
14+
import test_env
1615

1716
# connect as administrative user (usually SYSTEM or ADMIN)
18-
conn = cx_Oracle.connect(test_env.get_admin_connect_string())
17+
conn = oracledb.connect(test_env.get_admin_connect_string())
1918

2019
# drop existing users and editions, if applicable
2120
drop_test.drop_tests(conn)

test/test_1000_module.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
1000 - Module for testing top-level module methods
77
"""
88

9-
import test_env
10-
11-
import cx_Oracle as oracledb
129
import datetime
1310
import time
1411

12+
import cx_Oracle as oracledb
13+
import test_env
14+
1515
class TestCase(test_env.BaseTestCase):
1616
requires_connection = False
1717

0 commit comments

Comments
 (0)