Menu

Warnings won't go away

Help
John Speno
2006-02-28
2012-09-19
  • John Speno

    John Speno - 2006-02-28

    I'm getting warnings and I don't want to see them. :-)

    MySQLdb 1.2.0 final, python 2.4.2, mysql 4.1.14

    Code is basically this:

        self.connection = MySQLdb.Connection(db=database)
        self.connection.autocommit(1)
        cursor = MySQLdb.cursors.Cursor(self.connection)
        cursor.execute(query, args)
    

    Each time the last line exeucutes, I get something like this:

    Warning: Records: 315 Duplicates: 315 Warnings: 315
    cursor.execute(query, args)

    How can I explicity turn off the warnings? Thanks!

     
    • Mike Bernson

      Mike Bernson - 2006-07-02

      I am having the same problem with mysql version 5.0.22.

      MySQLdb is 1.2.1c3

      I get the following warnings:
      Warning: Records: 2 Duplicates: 0 Warnings: 1

      If I modify executemany in cursor.py
      from:
      if not m:
      r = 0
      for a in args:
      r = r + self.execute(query, a)
      return r
      to:
      r = 0
      for a in args:
      r = r + self.execute(query, a)
      return r

      The warning do not happen. Is there any way to get what the warning is. I have check and this is all that is being return to python.

      The more records that go into the insert the more warning I get.

       
      • Andy Dustman

        Andy Dustman - 2006-07-02

        Without your query and data and schema, it's pretty hard to guess. With MySQLdb-1.2.1 and MySQL-4.1 or newer, you should get individual warnings for each record. You are using a release candidate, and that one may not have the support for MySQL SHOW WARNINGS. Get 1.2.1_p2 and try again.

         
    • Andy Dustman

      Andy Dustman - 2006-02-28

      Read the python documentation for the warnings module.

      http://docs.python.org/lib/module-warnings.html

      Specifically read up on filterwarnings. You can also make all warnings raise exceptions (like what pre-1.2.0 did) by doing:

      warnings.filterwarnings("error", module="MySQLdb")

      (This is the opposite of what you asked; read the docs!)

      1.2.1 will include much more information about warnings. The above query would actually print 315 warnings. Who knows, they might be important...

       
      • Oleg Deribas

        Oleg Deribas - 2006-04-25

        But is there any way to see these warnings? I mean, warnings text instead of this: "Warning: Records: 315 Duplicates: 315 Warnings: 315" ?

         
        • Andy Dustman

          Andy Dustman - 2006-04-25

          With MySQL-4.1 and MySQLdb-1.2.1, yes, all the warnings are issued individually and have useful warning text.

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.