Recently i started learning python and ran it to issue while connecting python to oracle database.
It took me almost 1.5 hours to establish a connection from a python script to the Database I know.
Biggest challenge for the developer is knowing the
First Step:
The below query will give you the host name and Port no(Type=Local Listener)
select * from v$listener_network;
To get the SID user the below query
select instance_name "SID" from v$instance
User pip to install cx_oracle
import cx_Oracle
dsn_tns = cx_Oracle.makedsn('Hostname', 'portno', 'SID')
conn = cx_Oracle.connect(user='APPS', password='PWD', dsn=dsn_tns)
ver = conn.version.split(".")
print(ver)
print(ver[0])
print(ver[-1])
print(ver[1:4])
conn.close()
No comments:
Post a Comment