One possible solution is the introduction of Oracle Wallet. Creating an entry in Oracle Wallet includes:
- tnsname permission name set for the specified instance
- username and password
: Oracle sid, , ORCL, , , my_user. tnsnames.ora , /sid ORCL, :
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = my_ip)(PORT = 1528))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL)))
ORCL_MY_USER = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = my_ip)(PORT = 1528))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL)))
ORCL_MY_USER. , python script .
:
import cx_Oracle
db = cx_Oracle.connect( "/@ORCL_MY_USER" )
cursor = db.cursor()
r = cursor.execute( "SELECT , , account_status, default_tablespace, time_tablespace dba_users order by username" )
, , account_status, default_tablespace, time_tablespace :
print username, '\t', password, '\t', account_status, '\t', default_tablespace, '\t', temporary_tablespace