-
Notifications
You must be signed in to change notification settings - Fork 24
Description
In oracle, when you write sql code targeting a db object without specifying it's schema, oracle assumes that is the same as the username e.g. if user alice
connects to the db and executes SELECT * FROM mytable
, oracle will interpret it as SELECT * FROM alice.mytable
. If Alice wants her script to work with both dev_hr
and prod_hr
, she either has to prefix all of her object names with a variable (leading to clunky code), or run
with ORACLEDB.connect(password_variable='DB_PASSWORD') as conn:
etl.execute("ALTER SESSION SET CURRENT_SCHEMA=dev_hr", conn)`
every time she opens up a db connection.
It is possible to set the default schema for a session, so that you can specify what schema gets set before an unqualified db object name (see e.g. https://python-oracledb.readthedocs.io/en/latest/api_manual/connection.html#Connection.current_schema).
It would be useful if we added an attribute for DBParams that would allow setting the default schema, e.g.:
ORACLEDB = etl.DbParams(
dbtype='ORACLE',
host=os.getenv('DB_HOST'),
port=1521,
dbname=os.getenv('DB_NAME'),
user='alice',
current_schema='dev_hr'
)