arbitrarily truncate SQL log messages ? allow some option ?

Issue #2243 resolved
Former user created an issue

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)

  1. Mike Bayer repo owner

    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.

  2. Mike Bayer 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.

  3. Former user Account Deleted

    Yes, I mean the parameter lists :) For example executing conn.execute(sometable.insert(), some_huge_list_of_dicts).

  4. Mike Bayer 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

  5. Log in to comment