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
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
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
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
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,
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)))
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,
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
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
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
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
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
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
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()
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.
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
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
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
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
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()
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
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
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
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
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
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
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;
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
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...
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
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
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
32 matches
Mail list logo