annotate src/connections.c @ 80:6ec608cdd19c MySQLdb

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