游客发表

如何给Python的MySQL模块加功能

发帖时间:2025-11-04 17:29:25

如何给Python的MySQL模块加功能
复制diff --git a/_mysql.c b/_mysql.c   index d42cc54..61a9b34100644 --- a/_mysql.c   +++ b/_mysql.c   @@ -489,模块9 +489,10 @@ _mysql_ConnectionObject_Initialize(   "named_pipe", "init_command",   "read_default_file", "read_default_group",   "client_flag", "ssl",   -                                 "local_infile",   +                                 "local_infile", "read_timeout",   NULL } ;   int connect_timeout = 0;   +       int read_timeout = 0;   int compress = -1, named_pipe = -1, local_infile = -1;   char *init_command=NULL,   *read_default_file=NULL,   @@ -500,7 +501,7 @@ _mysql_ConnectionObject_Initialize(   self->converter = NULL;   self->open = 0;   check_server_init(-1);   -       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisssiOi:connect",   +       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisOiiisssiOii:connect",   kwlist,   &host, &user, &passwd, &db,   &port, &unix_socket, &conv,   @@ -509,7 +510,8 @@ _mysql_ConnectionObject_Initialize(   &init_command, &read_default_file,   &read_default_group,   &client_flag, &ssl,   -                                        &local_infile /* DO NOT PATCH FOR RECONNECT, IDIOTS   +                                        &local_infile, &read_timeout   +                                        /* DO NOT PATCH FOR RECONNECT, IDIOTS   IF YOU DO THIS, I WILL NOT SUPPORT YOUR PACKAGES. */   ))   return -1;   @@ -540,6 +542,12 @@ _mysql_ConnectionObject_Initialize(   mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT,   (char *)&timeout);   }   +   +        if (read_timeout) {   +                unsigned int timeout = read_timeout;   +                mysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT, (char *)&timeout);   +        }   +   if (compress != -1) {   mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);   client_flag |= CLIENT_COMPRESS;  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.

    热门排行

    友情链接