On 5/11/07, Mike Orr <[EMAIL PROTECTED]> wrote: > I've got a MySQL warning that's sabotaging my table-update program.
The table.insert() way gave the same warning, but I finally got it to work via plain MySQLdb: conn = engine.connect().connection cursor = conn.cursor() sql = "UPDATE Incident SET a=%(a)s ... WHERE ..." for i in session.query(Incident).select(): # Set local variables for the values to change. try: cursor.execute(sql, locals()) except _mysql_exceptions.Warning, e: print "Caught MySQLdb warning", e cursor.execute("SHOW WARNINGS") pprint.pprint(cursor.fetchall()) I thought maybe the problem was putting True and False in a TINYINT column, but that works interactively, even with the ORM. Or it may have been putting NULL in a non-NULL field, but SQLAlchemy does display a proper warning for this sometimes. So I couldn't find an error that definitively explained the warning. My only guess is maybe the the rows in the warning were somehow misaligned and it displayed the wrong row, or it only displayed one warning row and didn't check for more. It worked with the same data on my workstation, which is Ubuntu and something like MySQL 5.0.13. The server is Gentoo and a slightly older MySQL, 5.0.8 or so. So perhaps there was a bugfix in MySQL. Perhaps SQLAlchemy could raise a distinct SQLError subclass for warnings, and provide the unprocessed warnings in an attribute so the user could examine them. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---