Skip to content

Commit 09dc410

Browse files
Enable per-PDB DRCP for the sample container.
1 parent 89d1a46 commit 09dc410

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Thick Mode Changes
2727
standalone connections in addition to creating pools. For standalone
2828
connections, this parameter is optional.
2929

30+
Common Changes
31+
++++++++++++++
32+
33+
#) Improved samples and documentation.
3034

3135
oracledb 1.0.1 (June 2022)
3236
--------------------------

samples/connection_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def create_schema():
118118
id number generated by default as identity,
119119
username varchar2(40))';
120120
121-
insert into demo (username) values ('chris');
121+
execute immediate 'insert into demo (username) values (''chris'')';
122122
123123
commit;
124124
end;""")

samples/drcp_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def create_schema():
165165
id number generated by default as identity,
166166
username varchar2(40))';
167167
168-
insert into demo (username) values ('chris');
168+
execute immediate 'insert into demo (username) values (''chris'')';
169169
170170
commit;
171171
end;""")

samples/sample_container/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ USER root
4949

5050
RUN microdnf module disable python36 && \
5151
microdnf module enable python39 && \
52-
microdnf install python39 python39-pip python39-setuptools python39-wheel vim vi && \
52+
microdnf install python39 python39-pip python39-setuptools python39-wheel vim vi httpd-tools && \
5353
microdnf clean all
5454

5555
WORKDIR /samples/
@@ -63,7 +63,7 @@ RUN curl -LO https://github.com/oracle/python-oracledb/archive/refs/heads/main.
6363

6464
USER oracle
6565

66-
RUN python3 -m pip install oracledb --user
66+
RUN python3 -m pip install oracledb Flask --user --no-warn-script-location
6767

6868
ARG PYO_PASSWORD
6969

samples/sample_container/setup.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import os
1818
import time
1919

20+
oracledb.init_oracle_client()
21+
2022
pw = os.environ.get("ORACLE_PASSWORD")
2123
os.environ["PYO_SAMPLES_ADMIN_PASSWORD"] = pw
2224

@@ -40,14 +42,27 @@
4042
print("Try again in a few minutes")
4143
exit()
4244

43-
# Connect to the CDB to start DRCP because enable_per_pdb_drcp is FALSE by
44-
# default
45-
print("Starting DRCP pool")
46-
with oracledb.connect(user="sys",
47-
password=pw,
48-
dsn="localhost/XE",
49-
mode=oracledb.AUTH_MODE_SYSDBA) as connection:
50-
with connection.cursor() as cursor:
51-
cursor.callproc("dbms_connection_pool.start_pool")
45+
46+
print("Enabling per-PDB DRCP")
47+
48+
c = oracledb.connect(mode=oracledb.SYSDBA)
49+
cursor = c.cursor()
50+
cursor.execute("alter pluggable database all close")
51+
cursor.execute("alter system set enable_per_pdb_drcp=true scope=spfile sid='*'")
52+
53+
c = oracledb.connect(mode=oracledb.SYSDBA | oracledb.PRELIM_AUTH)
54+
c.startup(force=True)
55+
56+
c = oracledb.connect(mode=oracledb.SYSDBA)
57+
cursor = c.cursor()
58+
cursor.execute("alter database mount")
59+
cursor.execute("alter database open")
60+
61+
c = oracledb.connect(user="sys",
62+
password=pw,
63+
dsn="localhost/xepdb1",
64+
mode=oracledb.SYSDBA)
65+
cursor = c.cursor()
66+
cursor.callproc("dbms_connection_pool.start_pool")
5267

5368
# create_schema.py will be appended here by the Dockerfile

0 commit comments

Comments
 (0)