Thanks for your answers.
I ended up doing as Michael suggested:
engine = create_engine(conn_string)
def before_cursor_execute(conn, cursor, statement, parameters,
context, executemany):
log.info(re.sub('[\r\n]', '', '{} - {}'.format(statement,
parameters)))
event.lis
the easiest trick i came up with for this, was to create a "logging" table
in sqlalchemy/postgres and directly log the query into it.
my table looks roughly like this:
> id , timestamp, request_id ( if under pyramid ), query_id (if available,
guid assigned to different queries ), query, vars, e
One thing I like to do is grab the logger and just log my own line around
the query:
logger = logging.getLogger('sqlalchemy.engine')
logger.info('== ABOUT TO RUN MY QUERY ==')
# run your query
logger.info('== DONE RUNNING QUERY ==')
and then I grep the logs for "A
you can perhaps use a logging filter, just split the logs on a different token
other than the newline, or write your own log routine using the
before_cursor_execute event. there's a lot of ways to get this effect but none
are more convenient than another.
On Apr 22, 2014, at 10:49 AM, lev ka
Hi all,
I am execution a complicated query,
and when the query is written to the log, it breaks down into separate
lines.
This makes it really difficult to search the resulting log file for a query,
since grep will find only part of the query.
Is there a way to force the query to be written in