Comment 1 for bug 695514

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Yes, the RunTimeError is indeed a bug. It should have been self.client_flags = flags when an int is given.

It is, however, not recommended to use an int, but a list. From the docs (which we really need to push online one day..):

---

         MySQL uses client flags when connecting to enable or disable
         certain features. Using the *client_flags* arguments you have
         control of what is set. To find out what flags are available,
         you can use the following:

          >>> from mysql.connector.constants import ClientFlag
          >>> print '\n'.join(ClientFlag.get_full_info())

         If *client_flags* is not specified (that is, it is zero), defaults
         will used for MySQL v4.1 and later. If you specify an integer greater
         than ``0``, you need to make sure all flags are set. However, a much
         better way to set and unset flags is to use a list.

         For example, you want to set the FOUND_ROWS-flag:

         >>> mysql.connector.connect(client_flags=[ClientFlag.FOUND_ROWS])

         If you want to unset one of the defaults, e.g. LONG_FLAG:

         >>> mysql.connector.connect(client_flags=[
            ClientFlag.FOUND_ROWS,
            -ClientFlag.LONG_FLAG,
            ])

---

Thus, in this case, correct would be:

mysql.connector.connect( client_flags=[mysql.connector.ClientFlag.FOUND_ROWS] )

I found doing it using a sequence much more intuitive and clearer, what you think?