annotate src/connections.c @ 69:18e5892a5aed MySQLdb

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