MySQL instance initialization function. MySQL instance initialization function. It handles the connection arguments passed as positional or keyword arguments. Not all connection arguments are used with the initialization function. List of arguments which can be used: buffered, raw, charset_name, connection_timeout, use_unicode, auth_plugin Other connection argument are u
| 399 | @retval NULL Exception |
| 400 | */ |
| 401 | int |
| 402 | MySQL_init(MySQL *self, PyObject *args, PyObject *kwds) |
| 403 | { |
| 404 | PyObject *charset_name = NULL, *use_unicode = NULL, *auth_plugin = NULL, |
| 405 | *plugin_dir = NULL, *con_timeout = NULL; |
| 406 | |
| 407 | static char *kwlist[] = {"buffered", "raw", "charset_name", |
| 408 | "connection_timeout", "use_unicode", "auth_plugin", |
| 409 | "plugin_dir", NULL}; |
| 410 | |
| 411 | PyDateTime_IMPORT; |
| 412 | |
| 413 | // Initialization expect -1 when parsing arguments failed |
| 414 | if (!PyArg_ParseTupleAndKeywords( |
| 415 | args, kwds, "|O!O!O!O!O!O!O!", kwlist, &PyBool_Type, &self->buffered_at_connect, |
| 416 | &PyBool_Type, &self->raw_at_connect, &PyUnicode_Type, &charset_name, &PyLong_Type, |
| 417 | &con_timeout, &PyBool_Type, &use_unicode, &PyUnicode_Type, &auth_plugin, |
| 418 | &PyUnicode_Type, &plugin_dir)) |
| 419 | return -1; |
| 420 | |
| 421 | if (self->buffered_at_connect) { |
| 422 | self->buffered = self->buffered_at_connect; |
| 423 | } |
| 424 | |
| 425 | if (self->raw_at_connect) { |
| 426 | self->raw = self->raw_at_connect; |
| 427 | } |
| 428 | |
| 429 | if (use_unicode && use_unicode == Py_False) { |
| 430 | self->use_unicode = 0; |
| 431 | } |
| 432 | |
| 433 | if (charset_name) { |
| 434 | Py_DECREF(self->charset_name); |
| 435 | self->charset_name = charset_name; |
| 436 | Py_INCREF(self->charset_name); |
| 437 | } |
| 438 | |
| 439 | if (auth_plugin && strcmp(PyUnicode_AsUTF8(auth_plugin), "") != 0) { |
| 440 | Py_DECREF(self->auth_plugin); |
| 441 | self->auth_plugin = auth_plugin; |
| 442 | Py_INCREF(self->auth_plugin); |
| 443 | } |
| 444 | |
| 445 | if (plugin_dir) { |
| 446 | Py_DECREF(self->plugin_dir); |
| 447 | self->plugin_dir = plugin_dir; |
| 448 | Py_INCREF(self->plugin_dir); |
| 449 | } |
| 450 | |
| 451 | if (con_timeout) { |
| 452 | self->connection_timeout = (unsigned int)PyLong_AsUnsignedLong(con_timeout); |
| 453 | } |
| 454 | |
| 455 | return 0; |
| 456 | } |
| 457 | |
| 458 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…