Reputation: 77
Here is the code in the file con = cx_Oracle.connect('/@database_name')
.
This is setup to use my oracle wallet but its not working for some reason (giving me login denied). How do I enter my user name and password in this line of code? con = cx_Oracle.connect('/@database_name')
Upvotes: 2
Views: 6731
Reputation: 5141
You can use below,
import cx_Oracle
ip = '192.168.0.1'
port = 1521
service_name = 'my_service'
dsn = cx_Oracle.makedsn(ip, port, service_name=service_name)
db = cx_Oracle.connect('user', 'password', dsn)
Upvotes: 0
Reputation: 8518
You should take a look on
To use a wallet with cx_Oracle, you need first to configure the wallet, create the sqlnet.ora and tnsnames.ora files, and you need to use the dsn property
connection = cx_Oracle.connect(dsn="mynetalias", encoding="UTF-8")
Where mynetalias is the TNS entry in your tnsnames.ora
mynetalias =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yourhost )(PORT = yourport))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = yourservicename)
)
)
Be sure to have the sqlnet.ora configured for using the wallet
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = /your_wallet_path_directory)
)
)
SQLNET.WALLET_OVERRIDE = TRUE
Upvotes: 4