Mercurial > p > mysql-python > mysqldb-2
comparison MySQLdb/cursors.py @ 72:c0c00294239b MySQLdb
Check in some old changes
author | adustman |
---|---|
date | Thu, 18 Feb 2010 23:47:51 +0000 |
parents | 29b4cfd9af07 |
children | 80164eb2f090 |
comparison
equal
deleted
inserted
replaced
71:f06381a47ab0 | 72:c0c00294239b |
---|---|
1 """ | 1 """ |
2 MySQLdb Cursors | 2 MySQLdb Cursors |
3 --------------- | 3 --------------- |
4 | 4 |
5 This module implements Cursors of various types for MySQLdb. By | 5 This module implements the Cursor class. You should not try to |
6 default, MySQLdb uses the Cursor class. | 6 create Cursors direction; use connection.cursor() instead. |
7 | 7 |
8 """ | 8 """ |
9 | 9 |
10 __revision__ = "$Revision$"[11:-2] | 10 __revision__ = "$Revision$"[11:-2] |
11 __author__ = "$Author$"[9:-2] | 11 __author__ = "$Author$"[9:-2] |
25 | 25 |
26 description | 26 description |
27 A tuple of DB API 7-tuples describing the columns in | 27 A tuple of DB API 7-tuples describing the columns in |
28 the last executed query; see PEP-249 for details. | 28 the last executed query; see PEP-249 for details. |
29 | 29 |
30 description_flags | |
31 Tuple of column flags for last query, one entry per column | |
32 in the result set. Values correspond to those in | |
33 MySQLdb.constants.FLAG. See MySQL documentation (C API) | |
34 for more information. Non-standard extension. | |
35 | |
36 arraysize | 30 arraysize |
37 default number of rows fetchmany() will fetch | 31 default number of rows fetchmany() will fetch |
38 | 32 |
39 """ | 33 """ |
40 | 34 |
210 charset = self.connection.character_set_name() | 204 charset = self.connection.character_set_name() |
211 if isinstance(query, unicode): | 205 if isinstance(query, unicode): |
212 query = query.encode(charset) | 206 query = query.encode(charset) |
213 matched = INSERT_VALUES.match(query) | 207 matched = INSERT_VALUES.match(query) |
214 if not matched: | 208 if not matched: |
215 self.rowcount = sum([ self.execute(query, arg) for arg in args ]) | 209 self.rowcount = sum(( self.execute(query, arg) for arg in args )) |
216 return self.rowcount | 210 return self.rowcount |
217 | 211 |
218 start = matched.group('start') | 212 start = matched.group('start') |
213 values = matched.group('values') | |
219 end = matched.group('end') | 214 end = matched.group('end') |
220 values = matched.group('values') | 215 |
221 | |
222 try: | 216 try: |
223 sql_params = ( values % tuple(map(self.connection.literal, row)) for row in args ) | 217 sql_params = ( values % tuple(map(self.connection.literal, row)) for row in args ) |
224 multirow_query = '\n'.join([start, ',\n'.join(sql_params), end]) | 218 multirow_query = '\n'.join([start, ',\n'.join(sql_params), end]) |
225 self._executed = multirow_query | 219 self._executed = multirow_query |
226 self.rowcount = int(self._query(multirow_query)) | 220 self.rowcount = int(self._query(multirow_query)) |