import cx_Oracle
dsn_tns = cx_Oracle.makedsn(ip,port,SID)
connection = cx_Oracle.connect(username,password,dsn_tns)
cursor = connection.cursor()
cursor.execute("select ID1 from table1")
id1list = [r[0] for r in cursor]
for id1 in id1list:
print '-'*4, id1, '-‘*16
cursor.execute("select ID2 from table2 where ID = %s", id1))
for r in cursor:
print r
search `pymysql` may help you
安装模块 pymysql
import cx_Oracle
dsn_tns = cx_Oracle.makedsn(ip,port,SID)
connection = cx_Oracle.connect(username,password,dsn_tns)
cursor = connection.cursor()
ID1 = cursor.execute("select ID1 from table1")
ID2 = cursor.execute("select ID2 from table2 where ID = %s"%(ID1))