#6 Need more information from Warnings

closed
Andy Dustman
MySQLdb (19)
5
2012-09-19
2004-06-17
G. Cooper
No

Debugging form submissions that raise warnings on
insertion are quite difficult as there is little to no
information given by MySQLdb regarding the action. It
generally appears when you're sending data of one type
(such as a string) into fields of another type (such as
a date or integer).

Often it's fairly obvious. You have a limited number of
date fields, so make sure you're actually trying to
insert a date at that point. etc. but in massive tables
where the data inputted is even more convoluted
debugging becomes a tedious mess of one-at-a-time
"maybe this one is the problem" debugging.

If MySQLdb would only say what field(s) caused the
warning it would be immensely helpful.

Thanks for the great product! MySQLdb is invaluable!

Discussion

  • Andy Dustman
    Andy Dustman
    2004-06-18

    Logged In: YES
    user_id=71372

    Well, there's good news and bad news.

    In 1.1/1.2, warnings are flagged via the Python warnings
    subsystem. In other words, you don't get an exception
    raised, unless you have configured the warnings module to do so.

    Unfortunately, there is no way to find out from MySQL what
    field is the one that caused the warning to occur, or at
    least not in 4.0 and earlier. It might be possible with 4.1
    and newer, but the new API is not yet supported in MySQLdb,
    and is still stabilizing in 4.1 (recently all the API
    functions were renamed). The plan is to support this in 1.3/2.0.

     
  • Andy Dustman
    Andy Dustman
    2006-02-25

    Logged In: YES
    user_id=71372

    If prepared statements provide this information, I'll
    include it, but not in the 1.2 series.

     
  • Andy Dustman
    Andy Dustman
    2006-02-27

    Logged In: YES
    user_id=71372

    I found a way to support this in 1.2 for MySQL-4.1 server
    and newer. It's in CVS and should appear in 1.2.1 (within
    about a week).