In my python script I would like to trap a \"Data truncated for column \'xxx\'\" warning durnig my query using MySql.
I saw some posts suggesting the code below, but
I would try first to set the sql_mode. You can do this at the session level. If you execute a:
SET @@sql_mode:=TRADITIONAL;
(you could also set it at the server level, but you need access to the server to do that. and, that setting an still be overridden at the session level, so the bottom line is, always set it at the session level, immediately after establishing the connection)
then many things that are normally warnings become errors. I don't know how those manifest themselves at the python level, but the clear advantage is that the changes are not stored in the database. See: http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html#sqlmode_traditional