Skip to content

Commit d9be1ec

Browse files
Updates for cx_Oracle 7 and Oracle Client 18.3 as well as some miscellaneous
tweaks.
1 parent fc8cfbd commit d9be1ec

12 files changed

+148
-112
lines changed

samples/tutorial/Python-and-Oracle-Database-12c-Scripting-for-the-Future.html renamed to samples/tutorial/Python-and-Oracle-Database-Scripting-for-the-Future.html

Lines changed: 106 additions & 104 deletions
Large diffs are not rendered by default.

samples/tutorial/bind_sdo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
cur.execute("insert into testgeometry values (1, :obj)", obj = obj)
4444
print("Row added!")
4545

46+
# (Change below here)
47+
4648
# Query the row
4749
print("Querying row just inserted...")
4850
cur.execute("select id, geometry from testgeometry");

samples/tutorial/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# connect.py (Section 1.1 and 1.2)
2+
# connect.py (Section 1.2 and 1.3)
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------

samples/tutorial/drcp_query.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-------------------------------------------------------------------------------
2-
-- drcp_query.sql (Section 2.5)
2+
-- drcp_query.sql (Section 2.4 and 2.5)
33
-------------------------------------------------------------------------------
44

55
/*-----------------------------------------------------------------------------

samples/tutorial/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# query.py (Section 1.3)
2+
# query.py (Section 1.4 and 1.5)
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------

samples/tutorial/solutions/bind_sdo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
cur.execute("insert into testgeometry values (1, :objbv)", objbv = obj)
5151
print("Row added!")
5252

53+
# (Change below here)
54+
5355
# Define a function to dump the contents of an Oracle object
5456
def dumpobject(obj, prefix = " "):
5557
if obj.type.iscollection:

samples/tutorial/solutions/connect_pool2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
import db_config
1515

1616
pool = cx_Oracle.SessionPool(db_config.user, db_config.pw, db_config.dsn + ":pooled",
17-
min = 2, max = 5, increment = 1, threaded = True)
17+
min = 2, max = 5, increment = 1, threaded = True,
18+
getmode = cx_Oracle.SPOOL_ATTRVAL_WAIT)
1819

1920
def Query():
2021
con = pool.acquire(cclass="PYTHONHOL", purity=cx_Oracle.ATTR_PURITY_SELF)

samples/tutorial/solutions/query-2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# query.py (Section 1.4)
2+
# query.py (Section 1.5)
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------

samples/tutorial/solutions/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# query.py (Section 1.3)
2+
# query.py (Section 1.4 and 1.5)
33
#------------------------------------------------------------------------------
44

55
#------------------------------------------------------------------------------
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#------------------------------------------------------------------------------
2+
# query_scroll.py (Section 3.4)
3+
#------------------------------------------------------------------------------
4+
5+
#------------------------------------------------------------------------------
6+
# Copyright 2017, 2018, Oracle and/or its affiliates. All rights reserved.
7+
#------------------------------------------------------------------------------
8+
9+
from __future__ import print_function
10+
11+
import cx_Oracle
12+
import db_config
13+
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
15+
cur = con.cursor(scrollable = True)
16+
17+
cur.execute("select * from dept order by deptno")
18+
19+
cur.scroll(2, mode = "absolute") # go to second row
20+
print(cur.fetchone())
21+
22+
cur.scroll(-1) # go back one row
23+
print(cur.fetchone())
24+
25+
cur.scroll(1) # go to next row
26+
print(cur.fetchone())
27+
28+
cur.scroll(mode = "first") # go to first row
29+
print(cur.fetchone())

0 commit comments

Comments
 (0)