Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exposes two new methods to the Python MySQL connection object to allo…

…w mostly-asynchronous query calls.
  • Loading branch information...
commit ff365f38c52ba75c69de20bf884b5befcee220ac 1 parent bb905b7
@eliast authored
Showing with 54 additions and 0 deletions.
  1. +54 −0 _mysql.c
View
54 _mysql.c
@@ -1833,6 +1833,41 @@ _mysql_ConnectionObject_query(
return Py_None;
}
+static char _mysql_ConnectionObject_send_query__doc__[] =
+"Send the query and return so we can do something else.\n\
+Needs to be followed by mysql_read_query_result() when we want to\n\
+finish processing it.\n\
+" ;
+
+static PyObject *
+_mysql_ConnectionObject_send_query(
+ _mysql_ConnectionObject *self,
+ PyObject *args)
+{
+ char *query;
+ int len, r;
+ if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL;
+ check_connection(self);
+ r = mysql_send_query(&(self->connection), query, len);
+ if (r) return _mysql_Exception(self);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static char _mysql_ConnectionObject_read_query_result__doc__[] =
+"Returns the query results.\n" ;
+
+static PyObject *
+_mysql_ConnectionObject_read_query_result(
+ _mysql_ConnectionObject *self,
+ PyObject *args)
+{
+ int r;
+ r = self->connection.methods->read_query_result(&(self->connection));
+ 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\
@@ -2194,6 +2229,18 @@ static PyMethodDef _mysql_ConnectionObject_methods[] = {
},
#endif
{
+ "send_query",
+ (PyCFunction)_mysql_ConnectionObject_send_query,
+ METH_VARARGS,
+ _mysql_ConnectionObject_send_query__doc__
+ },
+ {
+ "read_query_result",
+ (PyCFunction)_mysql_ConnectionObject_read_query_result,
+ METH_VARARGS,
+ _mysql_ConnectionObject_read_query_result__doc__
+ },
+ {
"close",
(PyCFunction)_mysql_ConnectionObject_close,
METH_VARARGS,
@@ -2343,6 +2390,13 @@ static MyMemberlist(_mysql_ConnectionObject_memberlist)[] = {
"Type conversion mapping"
),
MyMember(
+ "fd",
+ T_UINT,
+ offsetof(_mysql_ConnectionObject,connection.net.fd),
+ RO,
+ "File descriptor of the server connection"
+ ),
+ MyMember(
"server_capabilities",
T_UINT,
offsetof(_mysql_ConnectionObject,connection.server_capabilities),
Please sign in to comment.
Something went wrong with that request. Please try again.