Actual SQL statement after bind variables specified
Posted
by
bioffe
on Stack Overflow
See other posts from Stack Overflow
or by bioffe
Published on 2011-01-14T17:22:21Z
Indexed on
2011/01/14
17:53 UTC
Read the original article
Hit count: 167
I am trying to log every SQL statement executed from my scripts. However I contemplate one problem I can not overcome.
Is there a way to compute actual SQL statement after bind variables were specified. In SQLite I had to compute the statement to be executed manually, using code below:
def __sql_to_str__(self, value,args):
for p in args:
if type(p) is IntType or p is None:
value = value.replace("?", str(p) ,1)
else:
value = value.replace("?",'\'' + p + '\'',1)
return value
It seems CX_Oracle has cursor.parse() facilities. But I can't figure out how to trick CX_Oracle to compute my query before its execution.
© Stack Overflow or respective owner