If you only need to use cx_Oracle
within that class, you can just set it as an attribute on this instance, for example:
class Database:
def __init__(self, config):
self.CONFIG=config
sys.path.append(self.CONFIG.cx_oracle_path)
from cx_Oracle import cx_Oracle
self.cx_Oracle = cx_Oracle
self.open()
def open(self):
self.CONNECTION = self.cx_Oracle.Connection(self.CONFIG.username,
self.CONFIG.password,
self.CONFIG.db_sid)
self.CURSOR = self.CONNECTION.cursor()
As a side note, if you are creating multiple Database
instances this is an odd approach, since you would end up adding multiple identical entries to sys.path
.