Skip to content

Commit d1dfa17

Browse files
Add Wallet for Session pool connections in oracle.py (geopython#1768)
* Added Wallet to Connection Pool * Flake8 changes * Flake8 changes * Feedback from Pull Request * Flake8
1 parent a806f89 commit d1dfa17

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

docs/source/data-publishing/ogcapi-features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Configured using environment variables.
420420
export ORACLE_POOL_MAX=10
421421
422422
423-
The ``ORACLE_POOL_MIN`` and ``ORACLE_POOL_MAX`` environment variables are used to trigger session pool creation in the Oracle Provider and the ``DatabaseConnection`` class. See https://python-oracledb.readthedocs.io/en/latest/api_manual/module.html#oracledb.create_pool for documentation of the ``create_pool`` function.
423+
The ``ORACLE_POOL_MIN`` and ``ORACLE_POOL_MAX`` environment variables are used to trigger session pool creation in the Oracle Provider and the ``DatabaseConnection`` class. Supports auth via user + password or wallet. For an example of the configuration see above at Oracle - Connection. See https://python-oracledb.readthedocs.io/en/latest/api_manual/module.html#oracledb.create_pool for documentation of the ``create_pool`` function.
424424

425425
If none or only one of the environment variables is set, session pooling will not be activated and standalone connections are established at every request.
426426

pygeoapi/provider/oracle.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,31 @@ def create_pool(cls, conn_dict, oracle_pool_min, oracle_pool_max):
6666
"""Initialize the connection pool for the class
6767
Lock is implemented before function call at __init__"""
6868
dsn = cls._make_dsn(conn_dict)
69+
70+
connect_kwargs = {
71+
'dsn': dsn,
72+
'min': oracle_pool_min,
73+
'max': oracle_pool_max,
74+
'increment': 1
75+
}
76+
6977
# Create the pool
78+
if conn_dict.get("external_auth") == "wallet":
79+
# If Auth is via Wallet you need to save a wallet under
80+
# the directory returned by this bash command if apache is used
81+
# cat /etc/passwd |grep apache
82+
# except another directory is specified in the sqlnet.ora file
83+
LOGGER.debug("Connection pool from wallet.")
84+
connect_kwargs["externalauth"] = True
85+
connect_kwargs["homogeneous"] = False
7086

71-
p = oracledb.create_pool(
72-
user=conn_dict["user"],
73-
password=conn_dict["password"],
74-
dsn=dsn,
75-
min=oracle_pool_min,
76-
max=oracle_pool_max,
77-
increment=1,
78-
)
79-
LOGGER.debug("Connection pool created successfully.")
87+
else:
88+
LOGGER.debug("Connection pool from user and password.")
89+
connect_kwargs["user"] = conn_dict["user"]
90+
connect_kwargs["password"] = conn_dict["password"]
91+
92+
p = oracledb.create_pool(**connect_kwargs)
93+
LOGGER.debug("Connection pool created successfully")
8094

8195
return p
8296

0 commit comments

Comments
 (0)