Reputation: 41
We are connecting to oracle from python using cx_oracle package. But the user_id, password and SID details are hardcoded in that. My question is, is there any way to create a Datasource kind of thing? Or how we will deploy such python script sin production?
The database is in a Linux box and python is installed in another Linux box(Weblogic server is also installed in this Linux box).
import cx_Oracle
con = cx_Oracle.connect('pythonhol/[email protected]/orcl')
print con.version
Expectation is :
Can we deploy python in a production instance? If yes how can we connect to the database by hiding the DB credentials?
Upvotes: 0
Views: 947
Reputation: 10721
Use some kind of 'external authentication', for example a wallet. See the cx_Oracle documentation https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html#connecting-using-external-authentication
In summary:
your scripts would connect like
connection = cx_Oracle.connect(dsn="mynetalias", encoding="UTF-8")
or
pool = cx_Oracle.SessionPool(externalauth=True, homogeneous=False, dsn="mynetalias",
encoding="UTF-8")
pool.acquire()
Upvotes: 1