Modified the HoL for Collaborate (#169) · datamk/python-cx_Oracle@bae5cbe · GitHub
Skip to content

Commit bae5cbe

Browse files
OsBlaineOraanthony-tuininga
authored andcommitted
Modified the HoL for Collaborate (oracle#169)
Modified samples and instructions to import common connection information from db_config.py or db_config.sql in order to make setup a bit more generic.
1 parent 4d37c85 commit bae5cbe

31 files changed

Lines changed: 234 additions & 94 deletions

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

Lines changed: 144 additions & 64 deletions
Large diffs are not rendered by default.

samples/tutorial/aq.py

Lines changed: 2 additions & 1 deletion

samples/tutorial/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/bind_insert.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@
88

99
set echo on
1010

11-
connect pythonhol/welcome@localhost/orclpdb
11+
@@db_config.sql
12+
connect &user/&pw@&connect_string
1213

13-
drop table mytab;
14+
begin
15+
execute immediate 'drop table mytab';
16+
exception
17+
when others then
18+
if sqlcode not in (-00942) then
19+
raise;
20+
end if;
21+
end;
22+
/
1423

1524
create table mytab (id number, data varchar2(20), constraint my_pk primary key (id));
1625

samples/tutorial/bind_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
cur = con.cursor()
1516

1617
cur.prepare("select * from dept where deptno = :id order by deptno")

samples/tutorial/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-
con = cx_Oracle.connect("pythonhol", "welcome", "localhost/orclpdb")
12+
import db_config
1313

14+
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
1415
cur = con.cursor()
1516

1617
# Create table

samples/tutorial/clob.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
print("Inserting data...")

samples/tutorial/clob_string.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
print("Inserting data...")

samples/tutorial/connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
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
print("Database version:", con.version)

samples/tutorial/connect_drcp.py

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)