Re: [sqlalchemy] Logging query in a single line

2014-04-24 Thread lev katzav
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

Re: [sqlalchemy] Logging query in a single line

2014-04-23 Thread Jonathan Vanasco
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

Re: [sqlalchemy] Logging query in a single line

2014-04-22 Thread Joshua Ma
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

Re: [sqlalchemy] Logging query in a single line

2014-04-22 Thread Michael Bayer
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

[sqlalchemy] Logging query in a single line

2014-04-22 Thread lev katzav
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