Thursday, 24 October 2019

Connect Oracle Python


Python : 3.7
need to have cx_oracle  : pip install cx_Oracle   ---in cmd / putty ( not in python shell)


import cx_Oracle
con = cx_Oracle.connect('MTDBA/Serv_7c@153.222.366.101/dbserv_7c')
cur = con.cursor()
#print (con.version)
cur.execute ("SELECT name,open_mode from v$database")
res = cur.fetchall () 
print (res)
con.close()

No comments:

Post a Comment