📄 _mysql.c
字号:
const char *s; int err; if (!PyArg_ParseTuple(args, "s", &s)) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS err = mysql_set_character_set(&(self->connection), s); Py_END_ALLOW_THREADS if (err) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}#endif#if MYSQL_VERSION_ID >= 50010static char _mysql_ConnectionObject_get_character_set_info__doc__[] ="Returns a dict with information about the current character set:\n\\n\collation\n\ collation name\n\name\n\ character set name\n\comment\n\ comment or descriptive name\n\dir\n\ character set directory\n\mbminlen\n\ min. length for multibyte string\n\mbmaxlen\n\ max. length for multibyte string\n\\n\Not all keys may be present, particularly dir.\n\\n\Non-standard.\n\";static PyObject *_mysql_ConnectionObject_get_character_set_info( _mysql_ConnectionObject *self, PyObject *args){ PyObject *result; MY_CHARSET_INFO cs; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); mysql_get_character_set_info(&(self->connection), &cs); if (!(result = PyDict_New())) return NULL; if (cs.csname) PyDict_SetItemString(result, "name", PyString_FromString(cs.csname)); if (cs.name) PyDict_SetItemString(result, "collation", PyString_FromString(cs.name)); if (cs.comment) PyDict_SetItemString(result, "comment", PyString_FromString(cs.comment)); if (cs.dir) PyDict_SetItemString(result, "dir", PyString_FromString(cs.dir)); PyDict_SetItemString(result, "mbminlen", PyInt_FromLong(cs.mbminlen)); PyDict_SetItemString(result, "mbmaxlen", PyInt_FromLong(cs.mbmaxlen)); return result;}#endifstatic char _mysql_get_client_info__doc__[] ="get_client_info() -- Returns a string that represents\n\the client library version.";static PyObject *_mysql_get_client_info( PyObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_server_init(NULL); return PyString_FromString(mysql_get_client_info());}static char _mysql_ConnectionObject_get_host_info__doc__[] ="Returns a string that represents the MySQL client library\n\version. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_get_host_info( _mysql_ConnectionObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); return PyString_FromString(mysql_get_host_info(&(self->connection)));}static char _mysql_ConnectionObject_get_proto_info__doc__[] ="Returns an unsigned integer representing the protocol version\n\used by the current connection. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_get_proto_info( _mysql_ConnectionObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); return PyInt_FromLong((long)mysql_get_proto_info(&(self->connection)));}static char _mysql_ConnectionObject_get_server_info__doc__[] ="Returns a string that represents the server version number.\n\Non-standard.\n\";static PyObject *_mysql_ConnectionObject_get_server_info( _mysql_ConnectionObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); return PyString_FromString(mysql_get_server_info(&(self->connection)));}static char _mysql_ConnectionObject_info__doc__[] ="Retrieves a string providing information about the most\n\recently executed query. Non-standard. Use messages or\n\Cursor.messages.\n\";static PyObject *_mysql_ConnectionObject_info( _mysql_ConnectionObject *self, PyObject *args){ const char *s; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); s = mysql_info(&(self->connection)); if (s) return PyString_FromString(s); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_insert_id__doc__[] ="Returns the ID generated for an AUTO_INCREMENT column by the previous\n\query. Use this function after you have performed an INSERT query into a\n\table that contains an AUTO_INCREMENT field.\n\\n\Note that this returns 0 if the previous query does not\n\generate an AUTO_INCREMENT value. If you need to save the value for\n\later, be sure to call this immediately after the query\n\that generates the value.\n\\n\The ID is updated after INSERT and UPDATE statements that generate\n\an AUTO_INCREMENT value or that set a column value to\n\LAST_INSERT_ID(expr). See section 6.3.5.2 Miscellaneous Functions\n\in the MySQL documentation.\n\\n\Also note that the value of the SQL LAST_INSERT_ID() function always\n\contains the most recently generated AUTO_INCREMENT value, and is not\n\reset between queries because the value of that function is maintained\n\in the server.\n\" ;static PyObject *_mysql_ConnectionObject_insert_id( _mysql_ConnectionObject *self, PyObject *args){ my_ulonglong r; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_insert_id(&(self->connection)); Py_END_ALLOW_THREADS return PyLong_FromUnsignedLongLong(r);}static char _mysql_ConnectionObject_kill__doc__[] ="Asks the server to kill the thread specified by pid.\n\Non-standard.";static PyObject *_mysql_ConnectionObject_kill( _mysql_ConnectionObject *self, PyObject *args){ unsigned long pid; int r; if (!PyArg_ParseTuple(args, "i:kill", &pid)) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_kill(&(self->connection), pid); Py_END_ALLOW_THREADS if (r) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_field_count__doc__[] ="Returns the number of columns for the most recent query on the\n\connection. Non-standard. Will probably give you bogus results\n\on most cursor classes. Use Cursor.rowcount.\n\";static PyObject *_mysql_ConnectionObject_field_count( _mysql_ConnectionObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self);#if MYSQL_VERSION_ID < 32224 return PyInt_FromLong((long)mysql_num_fields(&(self->connection)));#else return PyInt_FromLong((long)mysql_field_count(&(self->connection)));#endif} static char _mysql_ResultObject_num_fields__doc__[] ="Returns the number of fields (column) in the result." ;static PyObject *_mysql_ResultObject_num_fields( _mysql_ResultObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_result_connection(self); return PyInt_FromLong((long)mysql_num_fields(self->result));} static char _mysql_ResultObject_num_rows__doc__[] ="Returns the number of rows in the result set. Note that if\n\use=1, this will not return a valid value until the entire result\n\set has been read.\n\";static PyObject *_mysql_ResultObject_num_rows( _mysql_ResultObject *self, PyObject *args){ if (!PyArg_ParseTuple(args, "")) return NULL; check_result_connection(self); return PyLong_FromUnsignedLongLong(mysql_num_rows(self->result));} static char _mysql_ConnectionObject_ping__doc__[] ="Checks whether or not the connection to the server is\n\working. If it has gone down, an automatic reconnection is\n\attempted.\n\\n\This function can be used by clients that remain idle for a\n\long while, to check whether or not the server has closed the\n\connection and reconnect if necessary.\n\\n\New in 1.2.2: Accepts an optional reconnect parameter. If True,\n\then the client will attempt reconnection. Note that this setting\n\is persistent. By default, this is on in MySQL<5.0.3, and off\n\thereafter.\n\\n\Non-standard. You should assume that ping() performs an\n\implicit rollback; use only when starting a new transaction.\n\You have been warned.\n\";static PyObject *_mysql_ConnectionObject_ping( _mysql_ConnectionObject *self, PyObject *args){ int r, reconnect = -1; if (!PyArg_ParseTuple(args, "|I", &reconnect)) return NULL; check_connection(self); if ( reconnect != -1 ) self->connection.reconnect = reconnect; Py_BEGIN_ALLOW_THREADS r = mysql_ping(&(self->connection)); Py_END_ALLOW_THREADS if (r) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_query__doc__[] ="Execute a query. store_result() or use_result() will get the\n\result set, if any. Non-standard. Use cursor() to create a cursor,\n\then cursor.execute().\n\" ;static PyObject *_mysql_ConnectionObject_query( _mysql_ConnectionObject *self, PyObject *args){ char *query; int len, r; if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_real_query(&(self->connection), query, len); Py_END_ALLOW_THREADS if (r) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_select_db__doc__[] ="Causes the database specified by db to become the default\n\(current) database on the connection specified by mysql. In subsequent\n\queries, this database is the default for table references that do not\n\include an explicit database specifier.\n\\n\Fails unless the connected user can be authenticated as having\n\permission to use the database.\n\\n\Non-standard.\n\";static PyObject *_mysql_ConnectionObject_select_db( _mysql_ConnectionObject *self, PyObject *args){ char *db; int r; if (!PyArg_ParseTuple(args, "s:select_db", &db)) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_select_db(&(self->connection), db); Py_END_ALLOW_THREADS if (r) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_shutdown__doc__[] ="Asks the database server to shut down. The connected user must\n\have shutdown privileges. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_shutdown( _mysql_ConnectionObject *self, PyObject *args){ int r; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS r = mysql_shutdown(&(self->connection)#if MYSQL_VERSION_ID >= 40103 , SHUTDOWN_DEFAULT#endif ); Py_END_ALLOW_THREADS if (r) return _mysql_Exception(self); Py_INCREF(Py_None); return Py_None;}static char _mysql_ConnectionObject_stat__doc__[] ="Returns a character string containing information similar to\n\that provided by the mysqladmin status command. This includes\n\uptime in seconds and the number of running threads,\n\questions, reloads, and open tables. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_stat( _mysql_ConnectionObject *self, PyObject *args){ const char *s; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS s = mysql_stat(&(self->connection)); Py_END_ALLOW_THREADS if (!s) return _mysql_Exception(self); return PyString_FromString(s);}static char _mysql_ConnectionObject_store_result__doc__[] ="Returns a result object acquired by mysql_store_result\n\(results stored in the client). If no results are available,\n\None is returned. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_store_result( _mysql_ConnectionObject *self, PyObject *args){ PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; _mysql_ResultObject *r=NULL; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); arglist = Py_BuildValue("(OiO)", self, 0, self->converter); if (!arglist) goto error; kwarglist = PyDict_New(); if (!kwarglist) goto error; r = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type); if (!r) goto error; if (_mysql_ResultObject_Initialize(r, arglist, kwarglist)) goto error; result = (PyObject *) r; if (!(r->result)) { Py_DECREF(result); Py_INCREF(Py_None); result = Py_None; } error: Py_XDECREF(arglist); Py_XDECREF(kwarglist); return result;}static char _mysql_ConnectionObject_thread_id__doc__[] ="Returns the thread ID of the current connection. This value\n\can be used as an argument to kill() to kill the thread.\n\\n\If the connection is lost and you reconnect with ping(), the\n\thread ID will change. This means you should not get the\n\thread ID and store it for later. You should get it when you\n\need it.\n\\n\Non-standard.";static PyObject *_mysql_ConnectionObject_thread_id( _mysql_ConnectionObject *self, PyObject *args){ unsigned long pid; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); Py_BEGIN_ALLOW_THREADS pid = mysql_thread_id(&(self->connection)); Py_END_ALLOW_THREADS return PyInt_FromLong((long)pid);}static char _mysql_ConnectionObject_use_result__doc__[] ="Returns a result object acquired by mysql_use_result\n\(results stored in the server). If no results are available,\n\None is returned. Non-standard.\n\";static PyObject *_mysql_ConnectionObject_use_result( _mysql_ConnectionObject *self, PyObject *args){ PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; _mysql_ResultObject *r=NULL; if (!PyArg_ParseTuple(args, "")) return NULL; check_connection(self); arglist = Py_BuildValue("(OiO)", self, 1, self->converter); if (!arglist) return NULL; kwarglist = PyDict_New(); if (!kwarglist) goto error; r = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type); if (!r) goto error; result = (PyObject *) r; if (_mysql_ResultObject_Initialize(r, arglist, kwarglist)) goto error; if (!(r->result)) { Py_DECREF(result); Py_INCREF(Py_None); result = Py_None; } error: Py_DECREF(arglist); Py_XDECREF(kwarglist); return result;}static void_mysql_ConnectionObject_dealloc( _mysql_ConnectionObject *self){ PyObject *o; PyObject_GC_UnTrack(self); if (self->open) { o = _mysql_ConnectionObject_close(self, NULL); Py_XDECREF(o); } MyFree(self);}static PyObject *_mysql_ConnectionObject_repr( _mysql_ConnectionObject *self){ char buf[300]; if (self->open) sprintf(buf, "<_mysql.connection open to '%.256s' at %lx>", self->connection.host, (long)self); else sprintf(buf, "<_mysql.connection closed at %lx>", (long)self); return PyString_FromString(buf);}static char _mysql_ResultObject_data_seek__doc__[] ="data_seek(n) -- seek to row n of result set";static PyObject *_mysql_ResultObject_data_seek(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -