try:
    cursor.execute('DROP DATABASE IF EXISTS database_of_armaments')
except MySQLdb.ProgrammingError as e:
    print('There was a MySQL warning.  This is the info we have about it: %s' % e)
Trapping MySQL Warnings In Python