Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Menu

#9 MYSQL_OPT_RECONNECT support

open
MySQLdb (19)
5
2012-09-19
2006-04-29
No

Recent versions of MySQL (5.0.3+) changed the default
reconnect flag from 1 (auto-reconnect) to 0 (don't
reconnect automatically). From
http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html:

"Note that upon connection, mysql_real_connect() sets
the reconnect flag (part of the MYSQL structure) to a
value of 1 in versions of the API older than 5.0.3, or
0 in newer versions. A value of 1 for this flag
indicates that if a statement cannot be performed
because of a lost connection, to try reconnecting to
the server before giving up. As of MySQL 5.0.13, you
can use the MYSQL_OPT_RECONNECT option to
mysql_options() to control reconnection behavior."

I'd like to see this option supported by MySQLdb soon
so that I can get rid of those annoying "MySQL server
has gone away" errors.

Thanks,
George

Discussion

  • Andy Dustman

    Andy Dustman - 2006-05-01

    Logged In: YES
    user_id=71372

    It's too dangerous to have on by default when transactions
    may be open.

    You can use the set_server_option() method on the connection
    to set this, in theory.

     
  • Anonymous

    Anonymous - 2006-05-01

    Logged In: YES
    user_id=1065136

    I wasn't talking about having it as default; an extra
    keyword argument in Connection's constructor (such as
    use_unicode, local_infile, etc.) would be just as good.
    Calling set_server_option() requires to pass explicitly the
    value of MYSQL_OPT_RECONNECT in python (unless there is a
    way to refer to C enums by name in pure python, which I doubt).

     
  • Anonymous

    Anonymous - 2006-05-04

    Logged In: YES
    user_id=1065136

    Any updates on this ? If I offer to write a patch, is it
    going to be included ?

    Thanks,
    George

     
  • Markus Gritsch

    Markus Gritsch - 2006-12-29

    Logged In: YES
    user_id=553904
    Originator: NO

    You can use the set_server_option() method
    on the connection to set this, in theory.

    Can you give an example of how this call to set_server_option() should look like? I have not been able to get this working.

    Thanks,
    Markus

     

Log in to post a comment.