Hoi Mark,
There is an easy pattern for this, indeed.
Below you'll find a working example, in which you only need to put your
favourite connectstring.
It should be easy to adapt, even if you'd like to store the sql that is
used by using cx_Oracle. :)
Hoping that this helps,
Danny
Kapteyn Astronomical Institute / OmegaCEN e-mail: da...@as...
Postbus 800 tel.: +31 (0)50 3632454
9700 AV GRONINGEN fax.: +31 (0)50 3636100
THE NETHERLANDS http://www.astro-wise.org/
################################################################################
import cx_Oracle
# Derive your own Cursor class from the cx_Oracle one
# It
class MyCursor(cx_Oracle.Cursor):
def execute(self, *args):
print args
return cx_Oracle.Cursor.execute(self, *args)
# Derive your own Connection class from the cx_Oracle one
class MyConnection(cx_Oracle.Connection):
def cursor(self):
return MyCursor(self)
# Augment cx_Oracle.connect() by making it point to your own Connection class
cx_Oracle.connect = MyConnection
# From now on every code that uses cx_Oracle in the standard way will print
# each query plus arguments.
# If you want to switch back, just do cx_Oracle.connect = cx_Oracle.Connection
database = cx_Oracle.connect(connectstring)
cursor = database.cursor()
cursor.execute('SELECT SYSDATE FROM DUAL WHERE 5<>:something', {'something': 5})
print cursor.fetchone()
cursor.close()
database.close()
################################################################################
On Thu, Jun 29, 2006 at 05:57:27PM -0700, Mark Harrison wrote:
> For debugging, it would be nice to see all the sql lines
> that are being sent to Oracle for execution. Is there an
> easy way to do that?
>
> Many TIA!
> Mark
>
> --
> Mark Harrison
> Pixar Animation Studios
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> cx-oracle-users mailing list
> cx-...@li...
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
|