我正在使用 Amazon Work Space,并且我使用 VPN 通过 SSH Ubuntu 16.04 实例进行连接。我使用 python 来连接 Oracle 数据库 11g,我需要使用 cx_Oracle 连续查询通知,我创建了这段代码,从这个页面http://www.oracle.com/webfolder/technetwork/tutorials/obe/在 Internet 上查找db/oow10/python_db/python_db.htm:
import cx_Oracle
def DCNCallback(message):
print "Notification:"
for tab in message.tables:
print "Table:", tab.name
for row in tab.rows:
if row.operation & cx_Oracle.OPCODE_INSERT:
print "INSERT of rowid:", row.rowid
if row.operation & cx_Oracle.OPCODE_DELETE:
print "DELETE of rowid:", row.rowid
if row.operation & cx_Oracle.OPCODE_UPDATE:
print "UPDATE of rowid:", row.rowid
con = cx_Oracle.Connection("pythonhol/welcome@localhost/orcl",
events = True)
subscriptionInsDel = con.subscribe(callback = DCNCallback,
operations = cx_Oracle.OPCODE_INSERT | cx_Oracle.OPCODE_DELETE
| cx_Oracle.OPCODE_UPDATE,
rowids = True)
subscriptionInsDel.registerquery('select * from mytab')
raw_input("Hit Enter to conclude this demo\n")
我复制了这个示例并尝试在我的 Ubuntu 实例上运行,它没有任何错误,但是当我在 oracle 数据库上插入/更新/删除某些行时,Ubuntu 终端上没有任何反应。
我能做些什么 ?