Oracle Database Connection in Python

DB ACCESS

 

#############

#!/usr/bin/python
#!/scratch/sboda/python3/bin
import cx_Oracle
#con = cx_Oracle.connect('scott/tiger@127.0.0.1/l4.regress.rdbms.dev.us.oracle.com')
con = cx_Oracle.connect('scott/tiger@cid')
print (con.version)
cur = con.cursor()
#cur.execute('select * from emp where empno=7902')
cur.prepare('select * from emp where empno = :id')
cur.execute(None,{'id':7902})

#cur.execute('desc emp')
for result in cur:
print(result)
row = cur.fetchone()
print (row)
row = cur.fetchone()
print( row)
cur.execute(None,{'id':7788})
for result in cur:
print(result)

########