Below is my config.py file
ABC_TEST01_JJ = {"username" : 'NONE',"password" : 'NINU', "dsn" : 'ABC_TEST01_JJ', "port" : 1512, "encoding" : 'UTF-8'}
and this my python test.py script
import cx_Oracle
import config
connection = None
try:
env = input("Enter Environment name : ")
connection = cx_Oracle.connect(
config.format(env)["username"],
config.format(env)["password"],
config.format(env)["dsn"],
encoding=config.format(env)["encoding"])
# show the version of the Oracle Database
print(connection.version)
except cx_Oracle.Error as error:
print(error)
finally:
# release the connection
if connection:
connection.close()
I want to provide the env name as a prompt value and that value will go to config.env["username"] and it will pull all values from the config file but the issue is it is not taking the value of env name in config.format(env)["username"]. Not sure how to pass the value of variable env to there?