我正在尝试将审核和跟踪服务与 Firebird 2.5、Python 2.7 和 FDB 1.4 结合使用。
这就是我在空闲时所做的事情:
>>> import fdb
>>> svc = fdb.services.connect(password='masterkey', host='localhost')
>>> trace_config = """<database>
enabled true
log_connections true
log_transactions true
log_statement_finish true
time_threshold 0
</database>"""
>>> trace_id = svc.trace_start(trace_config, 'test_trace_2')
>>> svc.readline()
此后,我连接到数据库并执行一些选择等,但 readline 永远不会返回。
我是否遗漏了某个步骤?
最佳答案
原来有64kb的缓冲区用于输出。有一种直接获取输出的方法,来自 FDB 作者 Pavel Cisar:
while 1:
try:
line = svc._QS(fdb.ibase.isc_info_svc_line)
except fdb.OperationalError:
# It is routine for actions such as RESTORE to raise an
# exception at the end of their output. We ignore any such
# exception and assume that it was expected, which is somewhat
# risky. For example, suppose the network connection is broken
# while the client is receiving the action's output...
break
if not line: # we reached the end of output
break
print line
关于python - 如何通过 Python 使用 Firebird 审计和跟踪服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19521998/