arbitrarily truncate SQL log messages ? allow some option ?
I like SQLAlchemy's logging integration, but when the logged data would be huge (say I'm issuing a 15000-line INSERT statement), SQLAlchemy should recognize that and truncate logged information to a reasonable maximum (say 1000 characters). Otherwise I'm forced to disable logging.
Comments (9)
-
Account Deleted -
Account Deleted Sorry again :) It's solipsis at pitrou dot net.
-
repo owner - changed title to arbitrarily truncate SQL log messages ? allow some option ?
- changed milestone to 0.7.xx
Arbitrarily/implicitly truncating a generated SQL statement in the log sounds awfully unreasonable to me. I'm looking at a SQL statement right in my terminal right now that's 3195 characters, and I need every single one of them to paste into my command line tool for testing.
This use case can be handled easily within the Python logging module itself using a custom handler so for the moment I'm -1 on this as a SQLAlchemy behavior and -10 as an automatic behavior. Will forward to the development list for alternative suggestions.
-
repo owner - changed watchers to solipsis@pitrou.net
-
repo owner Oh, you're talking about the parameter lists? That's a different story. We do truncate those in exception messages already. Can you please add some specifics here as I am open to the latter and not the former.
-
Account Deleted Yes, I mean the parameter lists :) For example executing
conn.execute(sometable.insert(), some_huge_list_of_dicts)
. -
repo owner - changed milestone to 0.7.3
patch is attached some tests would be nice, for both exception throw (surprised we don't have that) as well as log output
-
repo owner - changed status to resolved
-
repo owner - removed milestone
Removing milestone: 0.7.3 (automated comment)
- Log in to comment
Ah, I forgot to add my e-mail address as cc: solipsis@pitrou.net. Sorry.