我正在使用亚马逊工作空间,我使用VPN通过SSH Ubuntu 16.04实例进行连接。我使用python连接Oracle Database 11g,我需要使用cx_Oracle连续查询通知,我从这个页面http://www.oracle.com/webfolder/technetwork/tutorials/obe/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终端上没有任何事情发生。
我该怎么办?
答案 0 :(得分:0)
Oracle服务器上是否已启用CQN?
您的非系统用户将需要启用cqn通知,例如:
UICollectionView
如果已完成此操作,则在运行python脚本时,在mytab表中执行插入/更新/删除操作,您是否看到python脚本的任何输出?请参阅此处以了解更多详细信息: https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_cqn.htm#CHEIFAEJ