Re: [sqlalchemy] Logging handler logic

2021-06-14 Thread jca...@gmail.com
Ok, Thanks for the patience, I should have looked at this closer. This now has reliable behavior for my use case by not using the echo flag. Thank you very much, jlc On Monday, June 14, 2021 at 5:33:41 AM UTC-6 Mike Bayer wrote: > the echo flag doesn't support customization like this. if you

Re: [sqlalchemy] Logging handler logic

2021-06-14 Thread Mike Bayer
the echo flag doesn't support customization like this. if you want to use your own handlers then you should use traditional logging steps; there's nothing the echo flag does that can't be accomplished using the logging API directly. On Sun, Jun 13, 2021, at 10:24 PM, jca...@gmail.com

Re: [sqlalchemy] Logging handler logic

2021-06-13 Thread Mike Bayer
the line you refer towards involves a flag called "echo", which is described at https://docs.sqlalchemy.org/en/14/core/engines.html#more-on-the-echo-flag and is entirely optional. if you don't use the echo flag, SQLAlchemy's logging behavior is completely traditional, with the caveat that the

[sqlalchemy] Logging handler logic

2021-06-13 Thread jca...@gmail.com
Hello everyone, After reviewing the handler logic, I am not clear that it implements logging within the pattern guidelines defined by the base logging implementation. In log.py#L103

[sqlalchemy] logging which relationship triggered a query?

2016-02-17 Thread Jonathan Vanasco
Something similar was asked on the list within the past 6 months, but I couldn't find it. We found a certain bit of code where one or more relationships were not properly eager loaded. This results in 300 postgres queries on a page instead of 30. The easiest way I could find the problem,

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)))

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,

[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

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

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

[sqlalchemy] logging question

2013-11-19 Thread Jon Nelson
Greetings, once more! I'm having some trouble with logging. Before I call any sqlalchemy functions or bits (but after sqlalchemy is imported), I use logging.config.fileConfig(...) to configure the logging. The file is set to configure sqlalchemy at NOTSET and sqlalchemy.engine and

Re: [sqlalchemy] logging question

2013-11-19 Thread Michael Bayer
On Nov 19, 2013, at 12:39 PM, Jon Nelson jnel...@jamponi.net wrote: Greetings, once more! I'm having some trouble with logging. Before I call any sqlalchemy functions or bits (but after sqlalchemy is imported), I use logging.config.fileConfig(...) to configure the logging. The file is

Re: [sqlalchemy] logging question

2013-11-19 Thread Jon Nelson
On Tue, Nov 19, 2013 at 12:17 PM, Michael Bayer mike...@zzzcomputing.com wrote: SQLAlchemy will affect the config of logging only if any of the “echo” flags are used - the effect of echo=True is that it calls logging.basicConfig(). This config will occur in addition to the config that you

Re: [sqlalchemy] logging

2013-02-05 Thread Michael Bayer
On Feb 5, 2013, at 1:19 PM, ru...@yahoo.com wrote: Actually I did not mean either declarative or classical mapping, I meant whatever style this is called: class User: pass class Address: pass engine = sa.create_engine (connectstr) connection = engine.connect()

Re: [sqlalchemy] logging

2013-02-04 Thread Michael Bayer
On Feb 4, 2013, at 1:04 AM, ru...@yahoo.com wrote: simply didn't get from the docs. Like the fact that I could create a mapped object simply with class User: pass rather than explicitly specifying all the attributes. Without that I wouldn't even be trying to use sqlalchemy today.

Re: [sqlalchemy] logging

2013-02-03 Thread rurpy
On 02/01/2013 11:10 AM, Michael Bayer wrote: On Feb 1, 2013, at 1:06 PM, ru...@yahoo.com mailto:ru...@yahoo.com ru...@yahoo.com wrote: I am working from Copeland's Sqlalchemy book please do not use this book. It is many years out of date, and was in fact already outdated the day it

[sqlalchemy] logging

2013-02-01 Thread rurpy
I am working from Copeland's Sqlalchemy book and he describes giving an echo_uow argument to Session() to enable unit-of- work messages. But perhaps the book refers to an old version of SA because I can find no documentation on that parameter (and both Session and sessionmaker reject it as

Re: [sqlalchemy] logging

2013-02-01 Thread Michael Bayer
On Feb 1, 2013, at 1:06 PM, ru...@yahoo.com wrote: I am working from Copeland's Sqlalchemy book please do not use this book. It is many years out of date, and was in fact already outdated the day it was published as we were up to 0.4 by then. The official documentation for SQLAlchemy is the

Re: [sqlalchemy] logging - get source line

2012-06-29 Thread Sebastian Elner
Ok, thank you for the advice! On 06/28/2012 07:41 PM, Michael Bayer wrote: I had no idea logging supported such a feature. However, I do know that intrinsic in a feature like that, is that determining source line needs to be configurable via a depth, that is, how many source lines up should

[sqlalchemy] logging - get source line

2012-06-28 Thread Sebastian Elner
Hello, I have an app here, which issues quite a number of sql statements. I would like to track down where in the code the sql is issued. Setting echo to True does not give the .py file and line number, so I setup my own logger as described in the docs: import logging logging.basicConfig()

Re: [sqlalchemy] logging - get source line

2012-06-28 Thread Michael Bayer
I had no idea logging supported such a feature. However, I do know that intrinsic in a feature like that, is that determining source line needs to be configurable via a depth, that is, how many source lines up should it go up the chain of sources for that call, since any particular call to

[sqlalchemy] logging user changes

2011-06-01 Thread Sebastian Elsner
Hello, I want to introduce logging to my SA application, so the users with elevated privileges can control what normal users change in the database. The log should go to the database not to a file. I have been thinking about a logger table like: table action: - column: datetime_of_action

Re: [sqlalchemy] Logging raw SQL statements

2011-02-09 Thread Michael Bayer
On Feb 9, 2011, at 2:58 PM, George V. Reilly wrote: Under SQLAlchemy 0.5, there used to be some logging setting that would show the actual SQL queries that were being made. Alas, I forget the exact invocation. Under SA 0.6, I have not been able to find a way to do this, short of hacking the

Re: [sqlalchemy] Logging raw SQL statements

2011-02-09 Thread George V. Reilly
The combination of create_engine(..., echo=True) and logging.basicConfig(level=logging.DEBUG) logging.getLogger('sqlalchemy').setLevel(logging.DEBUG) does the trick for me now. Thanks! /George -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

Re: [sqlalchemy] Logging raw SQL statements

2011-02-09 Thread Michael Bayer
in theory that would log all statements twice, only one should be needed. On Feb 9, 2011, at 5:33 PM, George V. Reilly wrote: The combination of create_engine(..., echo=True) and logging.basicConfig(level=logging.DEBUG) logging.getLogger('sqlalchemy').setLevel(logging.DEBUG) does the

[sqlalchemy] logging bug in 0.6.6?

2011-01-27 Thread Jon Nelson
I'm trying to diagnose an issue with temporary tables, so I cranked up the debug levels to DEBUG. I noticed something strange: 2011-01-27 09:34:12,818 DEBUG [sqlalchemy.pool.QueuePool.0x...e410] Connection connection object at 0x12e1d50; dsn: 'dbname=BLAH host=localhost user=BLAH

Re: [sqlalchemy] logging bug in 0.6.6?

2011-01-27 Thread Michael Bayer
On Jan 27, 2011, at 10:38 AM, Jon Nelson wrote: I'm trying to diagnose an issue with temporary tables, so I cranked up the debug levels to DEBUG. I noticed something strange: 2011-01-27 09:34:12,818 DEBUG [sqlalchemy.pool.QueuePool.0x...e410] Connection connection object at 0x12e1d50;

Re: [sqlalchemy] SqlAlchemy logging FAQ

2010-08-18 Thread Michael Bayer
On Aug 17, 2010, at 11:45 AM, Kent wrote: The logging FAQ states Therefore, when using Python logging, ensure all echo flags are set to False at all times, to avoid getting duplicate log lines. http://www.sqlalchemy.org/docs/dbengine.html#configuring-logging Is this no longer correct

Re: [sqlalchemy] SqlAlchemy logging FAQ

2010-08-18 Thread Kent Bower
Ah. Then the problem is in turbogears (which creates a default .ini file with): #echo shouldn't be used together with the logging module. sqlalchemy.echo = false sqlalchemy.echo_pool = false sqlalchemy.pool_recycle = 3600 ...logging sections...

[sqlalchemy] SqlAlchemy logging FAQ

2010-08-17 Thread Kent
The logging FAQ states Therefore, when using Python logging, ensure all echo flags are set to False at all times, to avoid getting duplicate log lines. http://www.sqlalchemy.org/docs/dbengine.html#configuring-logging Is this no longer correct information? I am using turbogears (which creates the

[sqlalchemy] logging after engine creation

2009-07-29 Thread Jon Nelson
I was recently trying to change the logging from the default to INFO for sqlalchemy.engine. This works great - so long as I do it at startup, before I make any connections, etc, however once I've created my engine instance I don't seem to be able to change the logging level, at least not in the

[sqlalchemy] Logging facilities of SQLAlchemy

2009-06-12 Thread General
Hello all. I think that logging in SQLAlchemy should be a bit more straightforward. First issue is _should_log_* properties. What for are they exist? Standard lib's logging module allows to fine-tune levels per-logger or per-handler. But with those strange props such simple code works not as it