Skip to content

Commit 6fd56a5

Browse files
OsBlaineOraanthony-tuininga
authored andcommitted
Modified the solutions of the HoL for Collaborate (#170)
added db_config and made changes to solutions to use db_config values
1 parent bae5cbe commit 6fd56a5

15 files changed

+32
-14
lines changed

samples/tutorial/solutions/aq-dequeue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import cx_Oracle
1212
import decimal
13+
import db_config
1314

14-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
15+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1516
cur = con.cursor()
1617

1718
BOOK_TYPE_NAME = "UDT_BOOK"

samples/tutorial/solutions/aq-enqueue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import cx_Oracle
1212
import decimal
13+
import db_config
1314

14-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
15+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1516
cur = con.cursor()
1617

1718
BOOK_TYPE_NAME = "UDT_BOOK"

samples/tutorial/solutions/aq-queuestart.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import cx_Oracle
1212
import decimal
13+
import db_config
1314

14-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
15+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1516
cur = con.cursor()
1617

1718
BOOK_TYPE_NAME = "UDT_BOOK"

samples/tutorial/solutions/bind_insert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415
cur = con.cursor()
1516

1617
rows = [ (1, "First" ), (2, "Second" ),

samples/tutorial/solutions/bind_sdo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415
cur = con.cursor()
1516

1617
# Create table

samples/tutorial/solutions/connect_pool2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import cx_Oracle
1212
import threading
1313
import time
14+
import db_config
1415

15-
pool = cx_Oracle.SessionPool("pythonhol", "welcome", "localhost/orclpdb:pooled",
16+
pool = cx_Oracle.SessionPool(db_config.user, db_config.pw, db_config.dsn + ":pooled",
1617
min = 2, max = 5, increment = 1, threaded = True)
1718

1819
def Query():
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
dirName = os.path.dirname(os.path.dirname(__file__))
4+
exec(open(os.path.join(dirName, "db_config.py"), "r").read())

samples/tutorial/solutions/query-2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415

1516
cur = con.cursor()
1617
cur.execute("select * from dept order by deptno")

samples/tutorial/solutions/query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415

1516
cur = con.cursor()
1617
cur.execute("select * from dept order by deptno")

samples/tutorial/solutions/query_many.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415
cur = con.cursor()
1516

1617
cur.execute("select * from dept order by deptno")

samples/tutorial/solutions/rowfactory.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import collections
1212
import cx_Oracle
13+
import db_config
1314

14-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
15+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1516

1617
cur = con.cursor()
1718

samples/tutorial/solutions/subclass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

1314
class MyConnection(cx_Oracle.Connection):
1415

1516
def __init__(self):
1617
print("Connecting to database")
17-
return super(MyConnection, self).__init__("pythonhol", "welcome", "localhost/orclpdb")
18+
return super(MyConnection, self).__init__(db_config.user, db_config.pw, db_config.dsn)
1819

1920
def cursor(self):
2021
return MyCursor(self)

samples/tutorial/solutions/type_converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
import cx_Oracle
1212
import decimal
13+
import db_config
1314

14-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
15+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1516
cur = con.cursor()
1617

1718
def ReturnNumbersAsDecimal(cursor, name, defaultType, size, precision, scale):

samples/tutorial/solutions/type_output.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415

1516
cur = con.cursor()
1617

samples/tutorial/solutions/versions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from __future__ import print_function
1010

1111
import cx_Oracle
12+
import db_config
1213

13-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415

1516
print(cx_Oracle.version)
1617
print("Database version:", con.version)

0 commit comments

Comments
 (0)