如何在python中使用oracle logminer?

时间:2017-09-25 11:07:38

标签: python oracle

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import cx_Oracle

我想在Python中使用dbms_logmnr_d.build(),但会发生以下错误:

  

追踪(最近的呼叫最后):
   文件" test.py",第10行,

x=c.callproc("EXECUTE dbms_logmnr_d.build(dictionary_filename => 'dictionary.ora', 
                dictionary_location =>'/u01/app/oracle/product/11.2.0/xe/LOGMNR')")
     

cx_Oracle.DatabaseError:
  ORA-06550:第1行,第15栏:
  PLS-00103:遇到以下其中一项时遇到符号DBMS_LOGMNR_D
   : = . ( @ % ; immediate
  代号: =代替DBMS_LOGMNR_D继续。

实施例

conn=cx_Oracle.connect('example/pass@localhost/XE')
c=conn.cursor()                                         
x=c.callproc("EXECUTE dbms_logmnr_d.build(dictionary_filename => 'dictionary.ora', dictionary_location =>'/u01/app/oracle/product/11.2.0/xe/LOGMNR')")
conn.commit();                  
c.close()                                                 
conn.close() 

1 个答案:

答案 0 :(得分:2)

您不应使用execute关键字,并单独传递参数:

c.callproc("dbms_logmnr_d.build", keywordParameters = dict(dictionary_filename = "dictionary.ora", dictionary_location = "/u01/app/oracle/product/11.2.0/xe/LOGMNR"))