Modified the solutions of the HoL for Collaborate (#170)

added db_config and made changes to solutions to use db_config values
This commit is contained in:
Blaine Carter 2018-04-21 11:08:04 -06:00 committed by Anthony Tuininga
parent bae5cbe76a
commit 6fd56a5d41
15 changed files with 32 additions and 14 deletions

View File

@ -10,8 +10,9 @@ from __future__ import print_function
import cx_Oracle
import decimal
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
BOOK_TYPE_NAME = "UDT_BOOK"

View File

@ -10,8 +10,9 @@ from __future__ import print_function
import cx_Oracle
import decimal
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
BOOK_TYPE_NAME = "UDT_BOOK"

View File

@ -10,8 +10,9 @@ from __future__ import print_function
import cx_Oracle
import decimal
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
BOOK_TYPE_NAME = "UDT_BOOK"

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
rows = [ (1, "First" ), (2, "Second" ),

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
# Create table

View File

@ -11,8 +11,9 @@ from __future__ import print_function
import cx_Oracle
import threading
import time
import db_config
pool = cx_Oracle.SessionPool("pythonhol", "welcome", "localhost/orclpdb:pooled",
pool = cx_Oracle.SessionPool(db_config.user, db_config.pw, db_config.dsn + ":pooled",
min = 2, max = 5, increment = 1, threaded = True)
def Query():

View File

@ -0,0 +1,4 @@
import os
dirName = os.path.dirname(os.path.dirname(__file__))
exec(open(os.path.join(dirName, "db_config.py"), "r").read())

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
cur.execute("select * from dept order by deptno")

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
cur.execute("select * from dept order by deptno")

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
cur.execute("select * from dept order by deptno")

View File

@ -10,8 +10,9 @@ from __future__ import print_function
import collections
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()

View File

@ -9,12 +9,13 @@
from __future__ import print_function
import cx_Oracle
import db_config
class MyConnection(cx_Oracle.Connection):
def __init__(self):
print("Connecting to database")
return super(MyConnection, self).__init__("pythonhol", "welcome", "localhost/orclpdb")
return super(MyConnection, self).__init__(db_config.user, db_config.pw, db_config.dsn)
def cursor(self):
return MyCursor(self)

View File

@ -10,8 +10,9 @@ from __future__ import print_function
import cx_Oracle
import decimal
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()
def ReturnNumbersAsDecimal(cursor, name, defaultType, size, precision, scale):

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
cur = con.cursor()

View File

@ -9,8 +9,9 @@
from __future__ import print_function
import cx_Oracle
import db_config
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
print(cx_Oracle.version)
print("Database version:", con.version)