How To Connect To An Oracle Database Using Cx_oracle With Service Name And Login?
I have a login, port number, host name and service name. How would I go about using the cx_Oracle.connect()?
Solution 1:
Something like this?
import cx_Oracle
con = cx_Oracle.connect('username/password@host_name/service_name')
print con.version
con.close()
Solution 2:
this works for me, you usually do need a port number
import cx_Oracle as orc
user= 'username'
pwd = 'password'
host = 'url.or.path.to.db'#could look like path or url depending on where it's hosted
service_name = 'servicename'
portno = 1234#note this is dummy port no
con = orc.connect(user, pwd, '{}:{}/{}'.format(host,portno,service_name))
Post a Comment for "How To Connect To An Oracle Database Using Cx_oracle With Service Name And Login?"