Skip to content

Commit

Permalink
Merge pull request #189 from Rudolf-AT/master
Browse files Browse the repository at this point in the history
Option "driverMode" to support oracledb "thick" mode
  • Loading branch information
amochin authored Nov 5, 2023
2 parents dc7e762 + d71fb8c commit 7e84d97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DatabaseLibrary/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def connect_to_database(
dbCharset=None,
dbDriver=None,
dbConfigFile=None,
driverMode=None,
):
"""
Loads the DB API 2.0 module given `dbapiModuleName` then uses it to
Expand Down Expand Up @@ -98,6 +99,7 @@ def connect_to_database(
dbPassword = dbPassword if dbPassword is not None else config.get("default", "dbPassword")
dbHost = dbHost or config.get("default", "dbHost") or "localhost"
dbPort = int(dbPort or config.get("default", "dbPort"))
driverMode = driverMode or config.get("default", "driverMode")

if dbapiModuleName == "excel" or dbapiModuleName == "excelrw":
self.db_api_module_name = "pyodbc"
Expand Down Expand Up @@ -192,6 +194,12 @@ def connect_to_database(
"Connecting using: %s.connect(user=%s, password=***, params=%s) "
% (dbapiModuleName, dbUsername, oracle_connection_params)
)
if "thick" in driverMode.lower():
mode_param = driverMode.lower().split(",lib_dir=")
if len(mode_param) == 2 and mode_param[0].lower() == "thick":
db_api_2.init_oracle_client(lib_dir=mode_param[1])
else:
db_api_2.init_oracle_client()
self._dbconnection = db_api_2.connect(user=dbUsername, password=dbPassword, params=oracle_connection_params)
self.omit_trailing_semicolon = True
elif dbapiModuleName in ["teradata"]:
Expand Down

0 comments on commit 7e84d97

Please sign in to comment.