Mercurial > p > mysql-python > mysqldb-2
annotate src/connections.c @ 80:6ec608cdd19c MySQLdb
Death to CVS! Long live Mercurial.
author | Kyle VanderBeek <kylev@kylev.com> |
---|---|
date | Thu, 17 Jun 2010 18:48:37 -0700 |
parents | 3b03cb566032 |
children |
rev | line source |
---|---|
29 | 1 /* -*- mode: C; indent-tabs-mode: t; c-basic-offset: 8; -*- */ |
2 | |
55
e606fd52e866
make things a little cleaner by moving to a src directory for the C code
kylev
parents:
42
diff
changeset
|
3 #include "mysqlmod.h" |
0 | 4 |
5 static int | |
6 _mysql_ConnectionObject_Initialize( | |
7 _mysql_ConnectionObject *self, | |
8 PyObject *args, | |
9 PyObject *kwargs) | |
10 { | |
11 MYSQL *conn = NULL; | |
12 PyObject *ssl = NULL; | |
13 #if HAVE_OPENSSL | |
14 char *key = NULL, *cert = NULL, *ca = NULL, | |
15 *capath = NULL, *cipher = NULL; | |
16 #endif | |
17 char *host = NULL, *user = NULL, *passwd = NULL, | |
18 *db = NULL, *unix_socket = NULL; | |
21 | 19 unsigned int port = 0; |
20 unsigned int client_flag = 0; | |
0 | 21 static char *kwlist[] = { "host", "user", "passwd", "db", "port", |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
22 "unix_socket", |
0 | 23 "connect_timeout", "compress", |
24 "named_pipe", "init_command", | |
25 "read_default_file", "read_default_group", | |
26 "client_flag", "ssl", | |
27 "local_infile", | |
28 NULL } ; | |
29 int connect_timeout = 0; | |
30 int compress = -1, named_pipe = -1, local_infile = -1; | |
31 char *init_command=NULL, | |
32 *read_default_file=NULL, | |
33 *read_default_group=NULL; | |
34 | |
35 self->open = 0; | |
36 check_server_init(-1); | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
37 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|ssssisiiisssiOi:connect", |
0 | 38 kwlist, |
39 &host, &user, &passwd, &db, | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
40 &port, &unix_socket, |
0 | 41 &connect_timeout, |
42 &compress, &named_pipe, | |
43 &init_command, &read_default_file, | |
44 &read_default_group, | |
45 &client_flag, &ssl, | |
46 &local_infile | |
47 )) | |
48 return -1; | |
49 | |
50 #define _stringsuck(d,t,s) {t=PyMapping_GetItemString(s,#d);\ | |
51 if(t){d=PyString_AsString(t);Py_DECREF(t);}\ | |
52 PyErr_Clear();} | |
53 | |
54 if (ssl) { | |
55 #if HAVE_OPENSSL | |
56 PyObject *value = NULL; | |
57 _stringsuck(ca, value, ssl); | |
58 _stringsuck(capath, value, ssl); | |
59 _stringsuck(cert, value, ssl); | |
60 _stringsuck(key, value, ssl); | |
61 _stringsuck(cipher, value, ssl); | |
62 #else | |
63 PyErr_SetString(_mysql_NotSupportedError, | |
64 "client library does not have SSL support"); | |
65 return -1; | |
66 #endif | |
67 } | |
68 | |
69 Py_BEGIN_ALLOW_THREADS ; | |
70 conn = mysql_init(&(self->connection)); | |
71 if (connect_timeout) { | |
72 unsigned int timeout = connect_timeout; | |
73 mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT, | |
74 (char *)&timeout); | |
75 } | |
76 if (compress != -1) { | |
77 mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0); | |
78 client_flag |= CLIENT_COMPRESS; | |
79 } | |
80 if (named_pipe != -1) | |
81 mysql_options(&(self->connection), MYSQL_OPT_NAMED_PIPE, 0); | |
82 if (init_command != NULL) | |
83 mysql_options(&(self->connection), MYSQL_INIT_COMMAND, init_command); | |
84 if (read_default_file != NULL) | |
85 mysql_options(&(self->connection), MYSQL_READ_DEFAULT_FILE, read_default_file); | |
86 if (read_default_group != NULL) | |
87 mysql_options(&(self->connection), MYSQL_READ_DEFAULT_GROUP, read_default_group); | |
88 | |
89 if (local_infile != -1) | |
90 mysql_options(&(self->connection), MYSQL_OPT_LOCAL_INFILE, (char *) &local_infile); | |
91 | |
92 #if HAVE_OPENSSL | |
93 if (ssl) | |
94 mysql_ssl_set(&(self->connection), | |
95 key, cert, ca, capath, cipher); | |
96 #endif | |
97 | |
98 conn = mysql_real_connect(&(self->connection), host, user, passwd, db, | |
99 port, unix_socket, client_flag); | |
100 | |
101 Py_END_ALLOW_THREADS ; | |
102 | |
103 if (!conn) { | |
104 _mysql_Exception(self); | |
105 return -1; | |
106 } | |
69
18e5892a5aed
Defer incrementing reference to the decoder stack until later so we don't have to
kylev
parents:
67
diff
changeset
|
107 |
0 | 108 /* |
109 PyType_GenericAlloc() automatically sets up GC allocation and | |
110 tracking for GC objects, at least in 2.2.1, so it does not need to | |
111 be done here. tp_dealloc still needs to call PyObject_GC_UnTrack(), | |
112 however. | |
113 */ | |
114 self->open = 1; | |
115 return 0; | |
116 } | |
117 | |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
118 char _mysql_connect__doc__[] = |
0 | 119 "Returns a MYSQL connection object. Exclusive use of\n\ |
120 keyword parameters strongly recommended. Consult the\n\ | |
121 MySQL C API documentation for more details.\n\ | |
122 \n\ | |
123 host\n\ | |
124 string, host to connect\n\ | |
125 \n\ | |
126 user\n\ | |
127 string, user to connect as\n\ | |
128 \n\ | |
129 passwd\n\ | |
130 string, password to use\n\ | |
131 \n\ | |
132 db\n\ | |
133 string, database to use\n\ | |
134 \n\ | |
135 port\n\ | |
136 integer, TCP/IP port to connect to\n\ | |
137 \n\ | |
138 unix_socket\n\ | |
139 string, location of unix_socket (UNIX-ish only)\n\ | |
140 \n\ | |
141 connect_timeout\n\ | |
142 number of seconds to wait before the connection\n\ | |
143 attempt fails.\n\ | |
144 \n\ | |
145 compress\n\ | |
146 if set, gzip compression is enabled\n\ | |
147 \n\ | |
148 named_pipe\n\ | |
149 if set, connect to server via named pipe (Windows only)\n\ | |
150 \n\ | |
151 init_command\n\ | |
152 command which is run once the connection is created\n\ | |
153 \n\ | |
154 read_default_file\n\ | |
155 see the MySQL documentation for mysql_options()\n\ | |
156 \n\ | |
157 read_default_group\n\ | |
158 see the MySQL documentation for mysql_options()\n\ | |
159 \n\ | |
160 client_flag\n\ | |
161 client flags from MySQLdb.constants.CLIENT\n\ | |
162 \n\ | |
163 load_infile\n\ | |
164 int, non-zero enables LOAD LOCAL INFILE, zero disables\n\ | |
165 \n\ | |
166 "; | |
167 | |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
168 PyObject * |
0 | 169 _mysql_connect( |
170 PyObject *self, | |
171 PyObject *args, | |
172 PyObject *kwargs) | |
173 { | |
174 _mysql_ConnectionObject *c=NULL; | |
175 | |
176 c = MyAlloc(_mysql_ConnectionObject, _mysql_ConnectionObject_Type); | |
177 if (c == NULL) return NULL; | |
178 if (_mysql_ConnectionObject_Initialize(c, args, kwargs)) { | |
179 Py_DECREF(c); | |
180 c = NULL; | |
181 } | |
182 return (PyObject *) c; | |
183 } | |
184 | |
185 static int _mysql_ConnectionObject_traverse( | |
186 _mysql_ConnectionObject *self, | |
187 visitproc visit, | |
188 void *arg) | |
189 { | |
190 return 0; | |
191 } | |
192 | |
193 static int _mysql_ConnectionObject_clear( | |
194 _mysql_ConnectionObject *self) | |
195 { | |
196 return 0; | |
197 } | |
198 | |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
199 extern PyObject * |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
200 _escape_item( |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
201 PyObject *item, |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
202 PyObject *d); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
203 |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
204 char _mysql_escape_string__doc__[] = |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
205 "escape_string(s) -- quote any SQL-interpreted characters in string s.\n\ |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
206 If you want quotes around your value, use string_literal(s) instead.\n\ |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
207 "; |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
208 |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
209 PyObject * |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
210 _mysql_escape_string( |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
211 _mysql_ConnectionObject *self, |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
212 PyObject *args) |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
213 { |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
214 PyObject *str; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
215 char *in, *out; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
216 int len, size; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
217 if (!PyArg_ParseTuple(args, "s#:escape_string", &in, &size)) return NULL; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
218 str = PyString_FromStringAndSize((char *) NULL, size*2+1); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
219 if (!str) return PyErr_NoMemory(); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
220 out = PyString_AS_STRING(str); |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
221 len = mysql_real_escape_string(&(self->connection), out, in, size); |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
222 if (_PyString_Resize(&str, len) < 0) return NULL; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
223 return (str); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
224 } |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
225 |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
226 char _mysql_string_literal__doc__[] = |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
227 "string_literal(s) -- converts string s into a SQL string literal.\n\ |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
228 This means, any special SQL characters are escaped, and it is enclosed\n\ |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
229 within single quotes. In other words, it performs:\n\ |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
230 \n\ |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
231 \"'%s'\" % escape_string(s)\n\ |
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
232 "; |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
233 |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
234 PyObject * |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
235 _mysql_string_literal( |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
236 _mysql_ConnectionObject *self, |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
237 PyObject *args) |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
238 { |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
239 PyObject *str; |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
240 char *in, *out; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
241 int len, size; |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
242 if (!PyArg_ParseTuple(args, "s#:string_literal", &in, &size)) return NULL; |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
243 str = PyString_FromStringAndSize((char *) NULL, size*2+3); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
244 if (!str) return PyErr_NoMemory(); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
245 out = PyString_AS_STRING(str); |
67
98d968f5af11
Reimplement MySQL->Python type conversion in C; much simpler and easier to deal with now. Hey, all my tests pass, so I guess that means I need to write some more tests.
adustman
parents:
55
diff
changeset
|
246 len = mysql_real_escape_string(&(self->connection), out+1, in, size); |
2
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
247 *out = *(out+len+1) = '\''; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
248 if (_PyString_Resize(&str, len+2) < 0) return NULL; |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
249 return (str); |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
250 } |
c0d1fc0429ce
Smashed _mysql.c with a great big hammer and got some smaller,
adustman
parents:
1
diff
changeset
|
251 |
0 | 252 static char _mysql_ConnectionObject_close__doc__[] = |
253 "Close the connection. No further activity possible."; | |
254 | |
255 static PyObject * | |
256 _mysql_ConnectionObject_close( | |
257 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
258 PyObject *unused) |
0 | 259 { |
260 if (self->open) { | |
261 Py_BEGIN_ALLOW_THREADS | |
262 mysql_close(&(self->connection)); | |
263 Py_END_ALLOW_THREADS | |
264 self->open = 0; | |
265 } else { | |
266 PyErr_SetString(_mysql_ProgrammingError, | |
267 "closing a closed connection"); | |
268 return NULL; | |
269 } | |
270 _mysql_ConnectionObject_clear(self); | |
271 Py_INCREF(Py_None); | |
272 return Py_None; | |
273 } | |
274 | |
275 static char _mysql_ConnectionObject_affected_rows__doc__ [] = | |
276 "Return number of rows affected by the last query.\n\ | |
277 Non-standard. Use Cursor.rowcount.\n\ | |
278 "; | |
279 | |
280 static PyObject * | |
281 _mysql_ConnectionObject_affected_rows( | |
282 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
283 PyObject *unused) |
0 | 284 { |
285 check_connection(self); | |
286 return PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection))); | |
287 } | |
288 | |
289 static char _mysql_ConnectionObject_dump_debug_info__doc__[] = | |
290 "Instructs the server to write some debug information to the\n\ | |
291 log. The connected user must have the process privilege for\n\ | |
292 this to work. Non-standard.\n\ | |
293 "; | |
294 | |
295 static PyObject * | |
296 _mysql_ConnectionObject_dump_debug_info( | |
297 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
298 PyObject *unused) |
0 | 299 { |
300 int err; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
301 |
0 | 302 check_connection(self); |
303 Py_BEGIN_ALLOW_THREADS | |
304 err = mysql_dump_debug_info(&(self->connection)); | |
305 Py_END_ALLOW_THREADS | |
306 if (err) return _mysql_Exception(self); | |
307 Py_INCREF(Py_None); | |
308 return Py_None; | |
309 } | |
310 | |
311 static char _mysql_ConnectionObject_autocommit__doc__[] = | |
312 "Set the autocommit mode. True values enable; False value disable.\n\ | |
313 "; | |
314 static PyObject * | |
315 _mysql_ConnectionObject_autocommit( | |
316 _mysql_ConnectionObject *self, | |
317 PyObject *args) | |
318 { | |
319 int flag, err; | |
320 if (!PyArg_ParseTuple(args, "i", &flag)) return NULL; | |
321 Py_BEGIN_ALLOW_THREADS | |
322 #if MYSQL_VERSION_ID >= 40100 | |
323 err = mysql_autocommit(&(self->connection), flag); | |
324 #else | |
325 { | |
326 char query[256]; | |
327 snprintf(query, 256, "SET AUTOCOMMIT=%d", flag); | |
328 err = mysql_query(&(self->connection), query); | |
329 } | |
330 #endif | |
331 Py_END_ALLOW_THREADS | |
332 if (err) return _mysql_Exception(self); | |
333 Py_INCREF(Py_None); | |
334 return Py_None; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
335 } |
0 | 336 |
337 static char _mysql_ConnectionObject_commit__doc__[] = | |
338 "Commits the current transaction\n\ | |
339 "; | |
340 static PyObject * | |
341 _mysql_ConnectionObject_commit( | |
342 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
343 PyObject *unused) |
0 | 344 { |
345 int err; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
346 |
0 | 347 Py_BEGIN_ALLOW_THREADS |
348 #if MYSQL_VERSION_ID >= 40100 | |
349 err = mysql_commit(&(self->connection)); | |
350 #else | |
351 err = mysql_query(&(self->connection), "COMMIT"); | |
352 #endif | |
353 Py_END_ALLOW_THREADS | |
354 if (err) return _mysql_Exception(self); | |
355 Py_INCREF(Py_None); | |
356 return Py_None; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
357 } |
0 | 358 |
359 static char _mysql_ConnectionObject_rollback__doc__[] = | |
360 "Rolls backs the current transaction\n\ | |
361 "; | |
362 static PyObject * | |
363 _mysql_ConnectionObject_rollback( | |
364 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
365 PyObject *unused) |
0 | 366 { |
367 int err; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
368 |
0 | 369 Py_BEGIN_ALLOW_THREADS |
370 #if MYSQL_VERSION_ID >= 40100 | |
371 err = mysql_rollback(&(self->connection)); | |
372 #else | |
373 err = mysql_query(&(self->connection), "ROLLBACK"); | |
374 #endif | |
375 Py_END_ALLOW_THREADS | |
376 if (err) return _mysql_Exception(self); | |
377 Py_INCREF(Py_None); | |
378 return Py_None; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
379 } |
0 | 380 |
381 static char _mysql_ConnectionObject_next_result__doc__[] = | |
382 "If more query results exist, next_result() reads the next query\n\ | |
383 results and returns the status back to application.\n\ | |
384 \n\ | |
385 After calling next_result() the state of the connection is as if\n\ | |
386 you had called query() for the next query. This means that you can\n\ | |
387 now call store_result(), warning_count(), affected_rows()\n\ | |
388 , and so forth. \n\ | |
389 \n\ | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
390 Returns True if there are more results.\n\ |
0 | 391 \n\ |
392 Non-standard.\n\ | |
393 "; | |
394 static PyObject * | |
395 _mysql_ConnectionObject_next_result( | |
396 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
397 PyObject *unused) |
0 | 398 { |
399 int err; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
400 |
0 | 401 Py_BEGIN_ALLOW_THREADS |
402 #if MYSQL_VERSION_ID >= 40100 | |
403 err = mysql_next_result(&(self->connection)); | |
404 #else | |
405 err = -1; | |
406 #endif | |
407 Py_END_ALLOW_THREADS | |
408 if (err > 0) return _mysql_Exception(self); | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
409 return PyInt_FromLong(err == 0); |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
410 } |
0 | 411 |
412 #if MYSQL_VERSION_ID >= 40100 | |
413 | |
414 static char _mysql_ConnectionObject_set_server_option__doc__[] = | |
415 "set_server_option(option) -- Enables or disables an option\n\ | |
416 for the connection.\n\ | |
417 \n\ | |
418 Non-standard.\n\ | |
419 "; | |
420 static PyObject * | |
421 _mysql_ConnectionObject_set_server_option( | |
422 _mysql_ConnectionObject *self, | |
423 PyObject *args) | |
424 { | |
425 int err, flags=0; | |
426 if (!PyArg_ParseTuple(args, "i", &flags)) | |
427 return NULL; | |
428 Py_BEGIN_ALLOW_THREADS | |
429 err = mysql_set_server_option(&(self->connection), flags); | |
430 Py_END_ALLOW_THREADS | |
431 if (err) return _mysql_Exception(self); | |
432 return PyInt_FromLong(err); | |
433 } | |
434 | |
435 static char _mysql_ConnectionObject_sqlstate__doc__[] = | |
436 "Returns a string containing the SQLSTATE error code\n\ | |
437 for the last error. The error code consists of five characters.\n\ | |
438 '00000' means \"no error.\" The values are specified by ANSI SQL\n\ | |
439 and ODBC. For a list of possible values, see section 23\n\ | |
440 Error Handling in MySQL in the MySQL Manual.\n\ | |
441 \n\ | |
442 Note that not all MySQL errors are yet mapped to SQLSTATE's.\n\ | |
443 The value 'HY000' (general error) is used for unmapped errors.\n\ | |
444 \n\ | |
445 Non-standard.\n\ | |
446 "; | |
447 static PyObject * | |
448 _mysql_ConnectionObject_sqlstate( | |
449 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
450 PyObject *unused) |
0 | 451 { |
452 return PyString_FromString(mysql_sqlstate(&(self->connection))); | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
453 } |
0 | 454 |
455 static char _mysql_ConnectionObject_warning_count__doc__[] = | |
456 "Returns the number of warnings generated during execution\n\ | |
457 of the previous SQL statement.\n\ | |
458 \n\ | |
459 Non-standard.\n\ | |
460 "; | |
461 static PyObject * | |
462 _mysql_ConnectionObject_warning_count( | |
463 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
464 PyObject *unused) |
0 | 465 { |
466 return PyInt_FromLong(mysql_warning_count(&(self->connection))); | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
467 } |
0 | 468 |
469 #endif | |
470 | |
471 static char _mysql_ConnectionObject_errno__doc__[] = | |
472 "Returns the error code for the most recently invoked API function\n\ | |
473 that can succeed or fail. A return value of zero means that no error\n\ | |
474 occurred.\n\ | |
475 "; | |
476 | |
477 static PyObject * | |
478 _mysql_ConnectionObject_errno( | |
479 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
480 PyObject *unused) |
0 | 481 { |
482 check_connection(self); | |
483 return PyInt_FromLong((long)mysql_errno(&(self->connection))); | |
484 } | |
485 | |
486 static char _mysql_ConnectionObject_error__doc__[] = | |
487 "Returns the error message for the most recently invoked API function\n\ | |
488 that can succeed or fail. An empty string ("") is returned if no error\n\ | |
489 occurred.\n\ | |
490 "; | |
491 | |
492 static PyObject * | |
493 _mysql_ConnectionObject_error( | |
494 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
495 PyObject *unused) |
0 | 496 { |
497 check_connection(self); | |
498 return PyString_FromString(mysql_error(&(self->connection))); | |
499 } | |
500 | |
501 #if MYSQL_VERSION_ID >= 32303 | |
502 | |
503 static char _mysql_ConnectionObject_change_user__doc__[] = | |
504 "Changes the user and causes the database specified by db to\n\ | |
505 become the default (current) database on the connection\n\ | |
506 specified by mysql. In subsequent queries, this database is\n\ | |
507 the default for table references that do not include an\n\ | |
508 explicit database specifier.\n\ | |
509 \n\ | |
510 This function was introduced in MySQL Version 3.23.3.\n\ | |
511 \n\ | |
512 Fails unless the connected user can be authenticated or if he\n\ | |
513 doesn't have permission to use the database. In this case the\n\ | |
514 user and database are not changed.\n\ | |
515 \n\ | |
516 The db parameter may be set to None if you don't want to have\n\ | |
517 a default database.\n\ | |
518 "; | |
519 | |
520 static PyObject * | |
521 _mysql_ConnectionObject_change_user( | |
522 _mysql_ConnectionObject *self, | |
523 PyObject *args, | |
524 PyObject *kwargs) | |
525 { | |
526 char *user, *pwd=NULL, *db=NULL; | |
527 int r; | |
528 static char *kwlist[] = { "user", "passwd", "db", NULL } ; | |
529 | |
530 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|ss:change_user", | |
531 kwlist, &user, &pwd, &db)) | |
532 return NULL; | |
533 check_connection(self); | |
534 Py_BEGIN_ALLOW_THREADS | |
535 r = mysql_change_user(&(self->connection), user, pwd, db); | |
536 Py_END_ALLOW_THREADS | |
537 if (r) return _mysql_Exception(self); | |
538 Py_INCREF(Py_None); | |
539 return Py_None; | |
540 } | |
541 #endif | |
542 | |
543 static char _mysql_ConnectionObject_character_set_name__doc__[] = | |
544 "Returns the default character set for the current connection.\n\ | |
545 Non-standard.\n\ | |
546 "; | |
547 | |
548 static PyObject * | |
549 _mysql_ConnectionObject_character_set_name( | |
550 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
551 PyObject *unused) |
0 | 552 { |
553 const char *s; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
554 |
0 | 555 check_connection(self); |
556 #if MYSQL_VERSION_ID >= 32321 | |
557 s = mysql_character_set_name(&(self->connection)); | |
558 #else | |
559 s = "latin1"; | |
560 #endif | |
561 return PyString_FromString(s); | |
562 } | |
563 | |
564 #if MYSQL_VERSION_ID >= 50007 | |
565 static char _mysql_ConnectionObject_set_character_set__doc__[] = | |
566 "Sets the default character set for the current connection.\n\ | |
567 Non-standard.\n\ | |
568 "; | |
569 | |
570 static PyObject * | |
571 _mysql_ConnectionObject_set_character_set( | |
572 _mysql_ConnectionObject *self, | |
573 PyObject *args) | |
574 { | |
575 const char *s; | |
576 int err; | |
577 if (!PyArg_ParseTuple(args, "s", &s)) return NULL; | |
578 check_connection(self); | |
579 Py_BEGIN_ALLOW_THREADS | |
580 err = mysql_set_character_set(&(self->connection), s); | |
581 Py_END_ALLOW_THREADS | |
582 if (err) return _mysql_Exception(self); | |
583 Py_INCREF(Py_None); | |
584 return Py_None; | |
585 } | |
586 #endif | |
587 | |
588 #if MYSQL_VERSION_ID >= 50010 | |
589 static char _mysql_ConnectionObject_get_character_set_info__doc__[] = | |
590 "Returns a dict with information about the current character set:\n\ | |
591 \n\ | |
592 collation\n\ | |
593 collation name\n\ | |
594 name\n\ | |
595 character set name\n\ | |
596 comment\n\ | |
597 comment or descriptive name\n\ | |
598 dir\n\ | |
599 character set directory\n\ | |
600 mbminlen\n\ | |
601 min. length for multibyte string\n\ | |
602 mbmaxlen\n\ | |
603 max. length for multibyte string\n\ | |
604 \n\ | |
605 Not all keys may be present, particularly dir.\n\ | |
606 \n\ | |
607 Non-standard.\n\ | |
608 "; | |
609 | |
610 static PyObject * | |
611 _mysql_ConnectionObject_get_character_set_info( | |
612 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
613 PyObject *unused) |
0 | 614 { |
615 PyObject *result; | |
616 MY_CHARSET_INFO cs; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
617 |
0 | 618 check_connection(self); |
619 mysql_get_character_set_info(&(self->connection), &cs); | |
620 if (!(result = PyDict_New())) return NULL; | |
621 if (cs.csname) | |
622 PyDict_SetItemString(result, "name", PyString_FromString(cs.csname)); | |
623 if (cs.name) | |
624 PyDict_SetItemString(result, "collation", PyString_FromString(cs.name)); | |
625 if (cs.comment) | |
626 PyDict_SetItemString(result, "comment", PyString_FromString(cs.comment)); | |
627 if (cs.dir) | |
628 PyDict_SetItemString(result, "dir", PyString_FromString(cs.dir)); | |
629 PyDict_SetItemString(result, "mbminlen", PyInt_FromLong(cs.mbminlen)); | |
630 PyDict_SetItemString(result, "mbmaxlen", PyInt_FromLong(cs.mbmaxlen)); | |
631 return result; | |
632 } | |
633 #endif | |
634 | |
635 static char _mysql_ConnectionObject_get_host_info__doc__[] = | |
636 "Returns a string that represents the MySQL client library\n\ | |
637 version. Non-standard.\n\ | |
638 "; | |
639 | |
640 static PyObject * | |
641 _mysql_ConnectionObject_get_host_info( | |
642 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
643 PyObject *unused) |
0 | 644 { |
645 check_connection(self); | |
646 return PyString_FromString(mysql_get_host_info(&(self->connection))); | |
647 } | |
648 | |
649 static char _mysql_ConnectionObject_get_proto_info__doc__[] = | |
650 "Returns an unsigned integer representing the protocol version\n\ | |
651 used by the current connection. Non-standard.\n\ | |
652 "; | |
653 | |
654 static PyObject * | |
655 _mysql_ConnectionObject_get_proto_info( | |
656 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
657 PyObject *unused) |
0 | 658 { |
659 check_connection(self); | |
660 return PyInt_FromLong((long)mysql_get_proto_info(&(self->connection))); | |
661 } | |
662 | |
663 static char _mysql_ConnectionObject_get_server_info__doc__[] = | |
664 "Returns a string that represents the server version number.\n\ | |
665 Non-standard.\n\ | |
666 "; | |
667 | |
668 static PyObject * | |
669 _mysql_ConnectionObject_get_server_info( | |
670 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
671 PyObject *unused) |
0 | 672 { |
673 check_connection(self); | |
674 return PyString_FromString(mysql_get_server_info(&(self->connection))); | |
675 } | |
676 | |
677 static char _mysql_ConnectionObject_info__doc__[] = | |
678 "Retrieves a string providing information about the most\n\ | |
679 recently executed query. Non-standard. Use messages or\n\ | |
680 Cursor.messages.\n\ | |
681 "; | |
682 | |
683 static PyObject * | |
684 _mysql_ConnectionObject_info( | |
685 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
686 PyObject *unused) |
0 | 687 { |
688 const char *s; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
689 |
0 | 690 check_connection(self); |
691 s = mysql_info(&(self->connection)); | |
692 if (s) return PyString_FromString(s); | |
693 Py_INCREF(Py_None); | |
694 return Py_None; | |
695 } | |
696 | |
697 static char _mysql_ConnectionObject_insert_id__doc__[] = | |
698 "Returns the ID generated for an AUTO_INCREMENT column by the previous\n\ | |
699 query. Use this function after you have performed an INSERT query into a\n\ | |
700 table that contains an AUTO_INCREMENT field.\n\ | |
701 \n\ | |
702 Note that this returns 0 if the previous query does not\n\ | |
703 generate an AUTO_INCREMENT value. If you need to save the value for\n\ | |
704 later, be sure to call this immediately after the query\n\ | |
705 that generates the value.\n\ | |
706 \n\ | |
707 The ID is updated after INSERT and UPDATE statements that generate\n\ | |
708 an AUTO_INCREMENT value or that set a column value to\n\ | |
709 LAST_INSERT_ID(expr). See section 6.3.5.2 Miscellaneous Functions\n\ | |
710 in the MySQL documentation.\n\ | |
711 \n\ | |
712 Also note that the value of the SQL LAST_INSERT_ID() function always\n\ | |
713 contains the most recently generated AUTO_INCREMENT value, and is not\n\ | |
714 reset between queries because the value of that function is maintained\n\ | |
715 in the server.\n\ | |
716 " ; | |
717 | |
718 static PyObject * | |
719 _mysql_ConnectionObject_insert_id( | |
720 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
721 PyObject *unused) |
0 | 722 { |
723 my_ulonglong r; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
724 |
0 | 725 check_connection(self); |
726 Py_BEGIN_ALLOW_THREADS | |
727 r = mysql_insert_id(&(self->connection)); | |
728 Py_END_ALLOW_THREADS | |
729 return PyLong_FromUnsignedLongLong(r); | |
730 } | |
731 | |
732 static char _mysql_ConnectionObject_kill__doc__[] = | |
733 "Asks the server to kill the thread specified by pid.\n\ | |
734 Non-standard."; | |
735 | |
736 static PyObject * | |
737 _mysql_ConnectionObject_kill( | |
738 _mysql_ConnectionObject *self, | |
739 PyObject *args) | |
740 { | |
741 unsigned long pid; | |
742 int r; | |
71 | 743 if (!PyArg_ParseTuple(args, "k:kill", &pid)) return NULL; |
0 | 744 check_connection(self); |
745 Py_BEGIN_ALLOW_THREADS | |
746 r = mysql_kill(&(self->connection), pid); | |
747 Py_END_ALLOW_THREADS | |
748 if (r) return _mysql_Exception(self); | |
749 Py_INCREF(Py_None); | |
750 return Py_None; | |
751 } | |
752 | |
753 static char _mysql_ConnectionObject_field_count__doc__[] = | |
754 "Returns the number of columns for the most recent query on the\n\ | |
755 connection. Non-standard. Will probably give you bogus results\n\ | |
756 on most cursor classes. Use Cursor.rowcount.\n\ | |
757 "; | |
758 | |
759 static PyObject * | |
760 _mysql_ConnectionObject_field_count( | |
761 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
762 PyObject *unused) |
0 | 763 { |
764 check_connection(self); | |
765 #if MYSQL_VERSION_ID < 32224 | |
766 return PyInt_FromLong((long)mysql_num_fields(&(self->connection))); | |
767 #else | |
768 return PyInt_FromLong((long)mysql_field_count(&(self->connection))); | |
769 #endif | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
770 } |
0 | 771 |
772 static char _mysql_ConnectionObject_ping__doc__[] = | |
773 "Checks whether or not the connection to the server is\n\ | |
774 working. If it has gone down, an automatic reconnection is\n\ | |
775 attempted.\n\ | |
776 \n\ | |
777 This function can be used by clients that remain idle for a\n\ | |
778 long while, to check whether or not the server has closed the\n\ | |
779 connection and reconnect if necessary.\n\ | |
780 \n\ | |
5 | 781 New in 1.2.2: Accepts an optional reconnect parameter. If True,\n\ |
782 then the client will attempt reconnection. Note that this setting\n\ | |
783 is persistent. By default, this is on in MySQL<5.0.3, and off\n\ | |
784 thereafter.\n\ | |
785 \n\ | |
786 Non-standard. You should assume that ping() performs an\n\ | |
787 implicit rollback; use only when starting a new transaction.\n\ | |
788 You have been warned.\n\ | |
0 | 789 "; |
790 | |
791 static PyObject * | |
792 _mysql_ConnectionObject_ping( | |
793 _mysql_ConnectionObject *self, | |
794 PyObject *args) | |
795 { | |
5 | 796 int r, reconnect = -1; |
797 if (!PyArg_ParseTuple(args, "|I", &reconnect)) return NULL; | |
0 | 798 check_connection(self); |
5 | 799 if ( reconnect != -1 ) self->connection.reconnect = reconnect; |
0 | 800 Py_BEGIN_ALLOW_THREADS |
801 r = mysql_ping(&(self->connection)); | |
802 Py_END_ALLOW_THREADS | |
803 if (r) return _mysql_Exception(self); | |
804 Py_INCREF(Py_None); | |
805 return Py_None; | |
806 } | |
807 | |
808 static char _mysql_ConnectionObject_query__doc__[] = | |
809 "Execute a query. store_result() or use_result() will get the\n\ | |
810 result set, if any. Non-standard. Use cursor() to create a cursor,\n\ | |
811 then cursor.execute().\n\ | |
812 " ; | |
813 | |
814 static PyObject * | |
815 _mysql_ConnectionObject_query( | |
816 _mysql_ConnectionObject *self, | |
817 PyObject *args) | |
818 { | |
819 char *query; | |
820 int len, r; | |
821 if (!PyArg_ParseTuple(args, "s#:query", &query, &len)) return NULL; | |
822 check_connection(self); | |
823 Py_BEGIN_ALLOW_THREADS | |
824 r = mysql_real_query(&(self->connection), query, len); | |
825 Py_END_ALLOW_THREADS | |
826 if (r) return _mysql_Exception(self); | |
827 Py_INCREF(Py_None); | |
828 return Py_None; | |
829 } | |
830 | |
831 | |
832 static char _mysql_ConnectionObject_select_db__doc__[] = | |
833 "Causes the database specified by db to become the default\n\ | |
834 (current) database on the connection specified by mysql. In subsequent\n\ | |
835 queries, this database is the default for table references that do not\n\ | |
836 include an explicit database specifier.\n\ | |
837 \n\ | |
838 Fails unless the connected user can be authenticated as having\n\ | |
839 permission to use the database.\n\ | |
840 \n\ | |
841 Non-standard.\n\ | |
842 "; | |
843 | |
844 static PyObject * | |
845 _mysql_ConnectionObject_select_db( | |
846 _mysql_ConnectionObject *self, | |
847 PyObject *args) | |
848 { | |
849 char *db; | |
850 int r; | |
851 if (!PyArg_ParseTuple(args, "s:select_db", &db)) return NULL; | |
852 check_connection(self); | |
853 Py_BEGIN_ALLOW_THREADS | |
854 r = mysql_select_db(&(self->connection), db); | |
855 Py_END_ALLOW_THREADS | |
856 if (r) return _mysql_Exception(self); | |
857 Py_INCREF(Py_None); | |
858 return Py_None; | |
859 } | |
860 | |
861 static char _mysql_ConnectionObject_shutdown__doc__[] = | |
862 "Asks the database server to shut down. The connected user must\n\ | |
863 have shutdown privileges. Non-standard.\n\ | |
864 "; | |
865 | |
866 static PyObject * | |
867 _mysql_ConnectionObject_shutdown( | |
868 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
869 PyObject *unused) |
0 | 870 { |
871 int r; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
872 |
0 | 873 check_connection(self); |
874 Py_BEGIN_ALLOW_THREADS | |
875 r = mysql_shutdown(&(self->connection) | |
876 #if MYSQL_VERSION_ID >= 40103 | |
877 , SHUTDOWN_DEFAULT | |
878 #endif | |
879 ); | |
880 Py_END_ALLOW_THREADS | |
881 if (r) return _mysql_Exception(self); | |
882 Py_INCREF(Py_None); | |
883 return Py_None; | |
884 } | |
885 | |
886 static char _mysql_ConnectionObject_stat__doc__[] = | |
887 "Returns a character string containing information similar to\n\ | |
888 that provided by the mysqladmin status command. This includes\n\ | |
889 uptime in seconds and the number of running threads,\n\ | |
890 questions, reloads, and open tables. Non-standard.\n\ | |
891 "; | |
892 | |
893 static PyObject * | |
894 _mysql_ConnectionObject_stat( | |
895 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
896 PyObject *unused) |
0 | 897 { |
898 const char *s; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
899 |
0 | 900 check_connection(self); |
901 Py_BEGIN_ALLOW_THREADS | |
902 s = mysql_stat(&(self->connection)); | |
903 Py_END_ALLOW_THREADS | |
904 if (!s) return _mysql_Exception(self); | |
905 return PyString_FromString(s); | |
906 } | |
907 | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
908 static char _mysql_ConnectionObject_get_result__doc__[] = |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
909 "Returns a result object. If use is True, mysql_use_result()\n\ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
910 is used; otherwise mysql_store_result() is used (the default).\n\ |
0 | 911 "; |
912 | |
913 static PyObject * | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
914 _mysql_ConnectionObject_get_result( |
0 | 915 _mysql_ConnectionObject *self, |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
916 PyObject *args, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
917 PyObject *kwargs) |
0 | 918 { |
919 PyObject *arglist=NULL, *kwarglist=NULL, *result=NULL; | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
920 static char *kwlist[] = {"use", NULL}; |
0 | 921 _mysql_ResultObject *r=NULL; |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
922 int use = 0; |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
923 |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
924 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:get_result", kwlist, &use)) return NULL; |
0 | 925 check_connection(self); |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
926 arglist = Py_BuildValue("(Oi)", self, use); |
0 | 927 if (!arglist) goto error; |
928 kwarglist = PyDict_New(); | |
929 if (!kwarglist) goto error; | |
930 r = MyAlloc(_mysql_ResultObject, _mysql_ResultObject_Type); | |
931 if (!r) goto error; | |
932 if (_mysql_ResultObject_Initialize(r, arglist, kwarglist)) | |
933 goto error; | |
934 result = (PyObject *) r; | |
935 if (!(r->result)) { | |
936 Py_DECREF(result); | |
937 Py_INCREF(Py_None); | |
938 result = Py_None; | |
939 } | |
940 error: | |
941 Py_XDECREF(arglist); | |
942 Py_XDECREF(kwarglist); | |
943 return result; | |
944 } | |
945 | |
946 static char _mysql_ConnectionObject_thread_id__doc__[] = | |
947 "Returns the thread ID of the current connection. This value\n\ | |
948 can be used as an argument to kill() to kill the thread.\n\ | |
949 \n\ | |
950 If the connection is lost and you reconnect with ping(), the\n\ | |
951 thread ID will change. This means you should not get the\n\ | |
952 thread ID and store it for later. You should get it when you\n\ | |
953 need it.\n\ | |
954 \n\ | |
955 Non-standard."; | |
956 | |
957 static PyObject * | |
958 _mysql_ConnectionObject_thread_id( | |
959 _mysql_ConnectionObject *self, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
960 PyObject *unused) |
0 | 961 { |
962 unsigned long pid; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
963 |
0 | 964 check_connection(self); |
965 Py_BEGIN_ALLOW_THREADS | |
966 pid = mysql_thread_id(&(self->connection)); | |
967 Py_END_ALLOW_THREADS | |
968 return PyInt_FromLong((long)pid); | |
969 } | |
970 | |
971 static void | |
972 _mysql_ConnectionObject_dealloc( | |
973 _mysql_ConnectionObject *self) | |
974 { | |
975 PyObject *o; | |
976 | |
977 PyObject_GC_UnTrack(self); | |
978 if (self->open) { | |
979 o = _mysql_ConnectionObject_close(self, NULL); | |
980 Py_XDECREF(o); | |
981 } | |
982 MyFree(self); | |
983 } | |
984 | |
985 static PyObject * | |
986 _mysql_ConnectionObject_repr( | |
987 _mysql_ConnectionObject *self) | |
988 { | |
989 char buf[300]; | |
990 if (self->open) | |
991 sprintf(buf, "<_mysql.connection open to '%.256s' at %lx>", | |
992 self->connection.host, | |
993 (long)self); | |
994 else | |
995 sprintf(buf, "<_mysql.connection closed at %lx>", | |
996 (long)self); | |
997 return PyString_FromString(buf); | |
998 } | |
999 | |
1000 static PyMethodDef _mysql_ConnectionObject_methods[] = { | |
1001 { | |
1002 "affected_rows", | |
1003 (PyCFunction)_mysql_ConnectionObject_affected_rows, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1004 METH_NOARGS, |
0 | 1005 _mysql_ConnectionObject_affected_rows__doc__ |
1006 }, | |
1007 { | |
1008 "autocommit", | |
1009 (PyCFunction)_mysql_ConnectionObject_autocommit, | |
1010 METH_VARARGS, | |
1011 _mysql_ConnectionObject_autocommit__doc__ | |
1012 }, | |
1013 { | |
1014 "commit", | |
1015 (PyCFunction)_mysql_ConnectionObject_commit, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1016 METH_NOARGS, |
0 | 1017 _mysql_ConnectionObject_commit__doc__ |
1018 }, | |
1019 { | |
1020 "rollback", | |
1021 (PyCFunction)_mysql_ConnectionObject_rollback, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1022 METH_NOARGS, |
0 | 1023 _mysql_ConnectionObject_rollback__doc__ |
1024 }, | |
1025 { | |
1026 "next_result", | |
1027 (PyCFunction)_mysql_ConnectionObject_next_result, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1028 METH_NOARGS, |
0 | 1029 _mysql_ConnectionObject_next_result__doc__ |
1030 }, | |
1031 #if MYSQL_VERSION_ID >= 40100 | |
1032 { | |
1033 "set_server_option", | |
1034 (PyCFunction)_mysql_ConnectionObject_set_server_option, | |
1035 METH_VARARGS, | |
1036 _mysql_ConnectionObject_set_server_option__doc__ | |
1037 }, | |
1038 { | |
1039 "sqlstate", | |
1040 (PyCFunction)_mysql_ConnectionObject_sqlstate, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1041 METH_NOARGS, |
0 | 1042 _mysql_ConnectionObject_sqlstate__doc__ |
1043 }, | |
1044 { | |
1045 "warning_count", | |
1046 (PyCFunction)_mysql_ConnectionObject_warning_count, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1047 METH_NOARGS, |
0 | 1048 _mysql_ConnectionObject_warning_count__doc__ |
1049 }, | |
1050 #endif | |
1051 #if MYSQL_VERSION_ID >= 32303 | |
1052 { | |
1053 "change_user", | |
1054 (PyCFunction)_mysql_ConnectionObject_change_user, | |
1055 METH_VARARGS | METH_KEYWORDS, | |
1056 _mysql_ConnectionObject_change_user__doc__ | |
1057 }, | |
1058 #endif | |
1059 { | |
1060 "character_set_name", | |
1061 (PyCFunction)_mysql_ConnectionObject_character_set_name, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1062 METH_NOARGS, |
0 | 1063 _mysql_ConnectionObject_character_set_name__doc__ |
1064 }, | |
1065 #if MYSQL_VERSION_ID >= 50007 | |
1066 { | |
1067 "set_character_set", | |
1068 (PyCFunction)_mysql_ConnectionObject_set_character_set, | |
1069 METH_VARARGS, | |
1070 _mysql_ConnectionObject_set_character_set__doc__ | |
1071 }, | |
1072 #endif | |
1073 #if MYSQL_VERSION_ID >= 50010 | |
1074 { | |
1075 "get_character_set_info", | |
1076 (PyCFunction)_mysql_ConnectionObject_get_character_set_info, | |
1077 METH_VARARGS, | |
1078 _mysql_ConnectionObject_get_character_set_info__doc__ | |
1079 }, | |
1080 #endif | |
1081 { | |
1082 "close", | |
1083 (PyCFunction)_mysql_ConnectionObject_close, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1084 METH_NOARGS, |
0 | 1085 _mysql_ConnectionObject_close__doc__ |
1086 }, | |
1087 { | |
1088 "dump_debug_info", | |
1089 (PyCFunction)_mysql_ConnectionObject_dump_debug_info, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1090 METH_NOARGS, |
0 | 1091 _mysql_ConnectionObject_dump_debug_info__doc__ |
1092 }, | |
1093 { | |
1094 "escape_string", | |
1095 (PyCFunction)_mysql_escape_string, | |
1096 METH_VARARGS, | |
1097 _mysql_escape_string__doc__ | |
1098 }, | |
1099 { | |
1100 "error", | |
1101 (PyCFunction)_mysql_ConnectionObject_error, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1102 METH_NOARGS, |
0 | 1103 _mysql_ConnectionObject_error__doc__ |
1104 }, | |
1105 { | |
1106 "errno", | |
1107 (PyCFunction)_mysql_ConnectionObject_errno, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1108 METH_NOARGS, |
0 | 1109 _mysql_ConnectionObject_errno__doc__ |
1110 }, | |
1111 { | |
1112 "field_count", | |
1113 (PyCFunction)_mysql_ConnectionObject_field_count, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1114 METH_NOARGS, |
0 | 1115 _mysql_ConnectionObject_field_count__doc__ |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1116 }, |
0 | 1117 { |
1118 "get_host_info", | |
1119 (PyCFunction)_mysql_ConnectionObject_get_host_info, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1120 METH_NOARGS, |
0 | 1121 _mysql_ConnectionObject_get_host_info__doc__ |
1122 }, | |
1123 { | |
1124 "get_proto_info", | |
1125 (PyCFunction)_mysql_ConnectionObject_get_proto_info, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1126 METH_NOARGS, |
0 | 1127 _mysql_ConnectionObject_get_proto_info__doc__ |
1128 }, | |
1129 { | |
75
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1130 "get_result", |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1131 (PyCFunction)_mysql_ConnectionObject_get_result, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1132 METH_VARARGS | METH_KEYWORDS, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1133 _mysql_ConnectionObject_get_result__doc__ |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1134 }, |
3b03cb566032
More serious restructuring and cleaning, especially in the handling
adustman
parents:
71
diff
changeset
|
1135 { |
0 | 1136 "get_server_info", |
1137 (PyCFunction)_mysql_ConnectionObject_get_server_info, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1138 METH_NOARGS, |
0 | 1139 _mysql_ConnectionObject_get_server_info__doc__ |
1140 }, | |
1141 { | |
1142 "info", | |
1143 (PyCFunction)_mysql_ConnectionObject_info, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1144 METH_NOARGS, |
0 | 1145 _mysql_ConnectionObject_info__doc__ |
1146 }, | |
1147 { | |
1148 "insert_id", | |
1149 (PyCFunction)_mysql_ConnectionObject_insert_id, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1150 METH_NOARGS, |
0 | 1151 _mysql_ConnectionObject_insert_id__doc__ |
1152 }, | |
1153 { | |
1154 "kill", | |
1155 (PyCFunction)_mysql_ConnectionObject_kill, | |
1156 METH_VARARGS, | |
1157 _mysql_ConnectionObject_kill__doc__ | |
1158 }, | |
1159 { | |
1160 "ping", | |
1161 (PyCFunction)_mysql_ConnectionObject_ping, | |
1162 METH_VARARGS, | |
1163 _mysql_ConnectionObject_ping__doc__ | |
1164 }, | |
1165 { | |
1166 "query", | |
1167 (PyCFunction)_mysql_ConnectionObject_query, | |
1168 METH_VARARGS, | |
1169 _mysql_ConnectionObject_query__doc__ | |
1170 }, | |
1171 { | |
1172 "select_db", | |
1173 (PyCFunction)_mysql_ConnectionObject_select_db, | |
1174 METH_VARARGS, | |
1175 _mysql_ConnectionObject_select_db__doc__ | |
1176 }, | |
1177 { | |
1178 "shutdown", | |
1179 (PyCFunction)_mysql_ConnectionObject_shutdown, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1180 METH_NOARGS, |
0 | 1181 _mysql_ConnectionObject_shutdown__doc__ |
1182 }, | |
1183 { | |
1184 "stat", | |
1185 (PyCFunction)_mysql_ConnectionObject_stat, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1186 METH_NOARGS, |
0 | 1187 _mysql_ConnectionObject_stat__doc__ |
1188 }, | |
1189 { | |
1190 "string_literal", | |
1191 (PyCFunction)_mysql_string_literal, | |
1192 METH_VARARGS, | |
1193 _mysql_string_literal__doc__}, | |
1194 { | |
1195 "thread_id", | |
1196 (PyCFunction)_mysql_ConnectionObject_thread_id, | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1197 METH_NOARGS, |
0 | 1198 _mysql_ConnectionObject_thread_id__doc__ |
1199 }, | |
1200 {NULL, NULL} /* sentinel */ | |
1201 }; | |
1202 | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1203 static struct PyMemberDef _mysql_ConnectionObject_memberlist[] = { |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1204 { |
0 | 1205 "open", |
1206 T_INT, | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1207 offsetof(_mysql_ConnectionObject, open), |
0 | 1208 RO, |
1209 "True if connection is open" | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1210 }, |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1211 { |
0 | 1212 "server_capabilities", |
1213 T_UINT, | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1214 offsetof(_mysql_ConnectionObject, connection.server_capabilities), |
0 | 1215 RO, |
1216 "Capabilites of server; consult MySQLdb.constants.CLIENT" | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1217 }, |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1218 { |
0 | 1219 "port", |
1220 T_UINT, | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1221 offsetof(_mysql_ConnectionObject, connection.port), |
0 | 1222 RO, |
1223 "TCP/IP port of the server connection" | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1224 }, |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1225 { |
0 | 1226 "client_flag", |
1227 T_UINT, | |
1228 RO, | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1229 offsetof(_mysql_ConnectionObject, connection.client_flag), |
0 | 1230 "Client flags; refer to MySQLdb.constants.CLIENT" |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1231 }, |
0 | 1232 {NULL} /* Sentinel */ |
1233 }; | |
25
25c5d3b241ba
Start converting some some things to METH_NOARGS to save invocation time, add
kylev
parents:
21
diff
changeset
|
1234 |
0 | 1235 static PyObject * |
1236 _mysql_ConnectionObject_getattr( | |
1237 _mysql_ConnectionObject *self, | |
1238 char *name) | |
1239 { | |
1240 PyObject *res; | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1241 struct PyMemberDef *l; |
0 | 1242 |
1243 res = Py_FindMethod(_mysql_ConnectionObject_methods, (PyObject *)self, name); | |
1244 if (res != NULL) | |
1245 return res; | |
1246 PyErr_Clear(); | |
1247 if (strcmp(name, "closed") == 0) | |
1248 return PyInt_FromLong((long)!(self->open)); | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1249 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1250 for (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++) { |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1251 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1252 return PyMember_GetOne((char *)self, l); |
0 | 1253 } |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1254 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1255 PyErr_SetString(PyExc_AttributeError, name); |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1256 return NULL; |
0 | 1257 } |
1258 | |
1259 static int | |
1260 _mysql_ConnectionObject_setattr( | |
1261 _mysql_ConnectionObject *self, | |
1262 char *name, | |
1263 PyObject *v) | |
1264 { | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1265 struct PyMemberDef *l; |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1266 |
0 | 1267 if (v == NULL) { |
1268 PyErr_SetString(PyExc_AttributeError, | |
1269 "can't delete connection attributes"); | |
1270 return -1; | |
1271 } | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1272 |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1273 for (l = _mysql_ConnectionObject_memberlist; l->name != NULL; l++) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1274 if (strcmp(l->name, name) == 0) |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1275 return PyMember_SetOne((char *)self, l, v); |
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1276 |
0 | 1277 PyErr_SetString(PyExc_AttributeError, name); |
1278 return -1; | |
1279 } | |
1280 | |
1281 PyTypeObject _mysql_ConnectionObject_Type = { | |
1282 PyObject_HEAD_INIT(NULL) | |
1283 0, | |
1284 "_mysql.connection", /* (char *)tp_name For printing */ | |
29 | 1285 sizeof(_mysql_ConnectionObject), /* tp_basicsize */ |
0 | 1286 0, |
1287 (destructor)_mysql_ConnectionObject_dealloc, /* tp_dealloc */ | |
1288 0, /*tp_print*/ | |
1289 (getattrfunc)_mysql_ConnectionObject_getattr, /* tp_getattr */ | |
1290 (setattrfunc)_mysql_ConnectionObject_setattr, /* tp_setattr */ | |
1291 0, /*tp_compare*/ | |
1292 (reprfunc)_mysql_ConnectionObject_repr, /* tp_repr */ | |
29 | 1293 |
0 | 1294 /* Method suites for standard classes */ |
29 | 1295 |
0 | 1296 0, /* (PyNumberMethods *) tp_as_number */ |
1297 0, /* (PySequenceMethods *) tp_as_sequence */ | |
1298 0, /* (PyMappingMethods *) tp_as_mapping */ | |
29 | 1299 |
0 | 1300 /* More standard operations (here for binary compatibility) */ |
29 | 1301 |
0 | 1302 0, /* (hashfunc) tp_hash */ |
1303 0, /* (ternaryfunc) tp_call */ | |
1304 0, /* (reprfunc) tp_str */ | |
1305 0, /* (getattrofunc) tp_getattro */ | |
1306 0, /* (setattrofunc) tp_setattro */ | |
29 | 1307 |
0 | 1308 /* Functions to access object as input/output buffer */ |
1309 0, /* (PyBufferProcs *) tp_as_buffer */ | |
29 | 1310 |
0 | 1311 /* Flags to define presence of optional/expanded features */ |
1312 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, | |
29 | 1313 |
0 | 1314 _mysql_connect__doc__, /* (char *) tp_doc Documentation string */ |
29 | 1315 |
0 | 1316 /* call function for all accessible objects */ |
29 | 1317 (traverseproc)_mysql_ConnectionObject_traverse, /* tp_traverse */ |
1318 | |
0 | 1319 /* delete references to contained objects */ |
29 | 1320 (inquiry)_mysql_ConnectionObject_clear, /* tp_clear */ |
1321 | |
0 | 1322 /* rich comparisons */ |
1323 0, /* (richcmpfunc) tp_richcompare */ | |
29 | 1324 |
0 | 1325 /* weak reference enabler */ |
1326 0, /* (long) tp_weaklistoffset */ | |
29 | 1327 |
0 | 1328 /* Iterators */ |
1329 0, /* (getiterfunc) tp_iter */ | |
1330 0, /* (iternextfunc) tp_iternext */ | |
29 | 1331 |
0 | 1332 /* Attribute descriptor and subclassing stuff */ |
1333 (struct PyMethodDef *)_mysql_ConnectionObject_methods, /* tp_methods */ | |
42
fdf0cabb27be
Member stuff is stable post py2.2, so remove the MyMember* workarounds
kylev
parents:
29
diff
changeset
|
1334 (struct PyMemberDef *)_mysql_ConnectionObject_memberlist, /* tp_members */ |
0 | 1335 0, /* (struct getsetlist *) tp_getset; */ |
1336 0, /* (struct _typeobject *) tp_base; */ | |
1337 0, /* (PyObject *) tp_dict */ | |
1338 0, /* (descrgetfunc) tp_descr_get */ | |
1339 0, /* (descrsetfunc) tp_descr_set */ | |
1340 0, /* (long) tp_dictoffset */ | |
1341 (initproc)_mysql_ConnectionObject_Initialize, /* tp_init */ | |
1342 NULL, /* tp_alloc */ | |
1343 NULL, /* tp_new */ | |
29 | 1344 NULL, /* tp_free Low-level free-memory routine */ |
0 | 1345 0, /* (PyObject *) tp_bases */ |
1346 0, /* (PyObject *) tp_mro method resolution order */ | |
1347 0, /* (PyObject *) tp_defined */ | |
29 | 1348 }; |