Mercurial > p > mysql-python > mysqldb-2
diff MySQLdb/cursors.py @ 18:d55bfb1a4701 MySQLdb
Tons of changes from major refactoring/cleanup. This is all really broken
right now. In particular, all results are returned as strings.
author | adustman |
---|---|
date | Fri, 14 Mar 2008 23:06:29 +0000 |
parents | 7773efbe9b30 |
children | 10038670b963 |
line wrap: on
line diff
--- a/MySQLdb/cursors.py Tue Feb 27 00:58:49 2007 +0000 +++ b/MySQLdb/cursors.py Fri Mar 14 23:06:29 2008 +0000 @@ -35,7 +35,7 @@ """ - from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \ + from MySQLdb.exceptions import MySQLError, Warning, Error, InterfaceError, \ DatabaseError, DataError, OperationalError, IntegrityError, \ InternalError, ProgrammingError, NotSupportedError @@ -68,7 +68,10 @@ """Close the cursor. No further queries will be possible.""" if not self.connection: return - while self.nextset(): + try: + while self.nextset(): + pass + except: pass self.connection = None @@ -142,7 +145,7 @@ Raises ProgrammingError if the connection has been closed.""" if not self.connection: self.errorhandler(self, self.ProgrammingError, "cursor closed") - return self.connection + return self.connection._db def execute(self, query, args=None): """Execute a query. @@ -159,12 +162,12 @@ """ from sys import exc_info del self.messages[:] - connection = self._get_db() - charset = connection.character_set_name() + db = self._get_db() + charset = db.character_set_name() if isinstance(query, unicode): query = query.encode(charset) if args is not None: - query = query % connection.literal(args) + query = query % self.connection.literal(args) try: result = self._query(query) except TypeError, msg: @@ -205,10 +208,10 @@ """ del self.messages[:] - connection = self._get_db() + db = self._get_db() if not args: return - charset = connection.character_set_name() + charset = self.connection.character_set_name() if isinstance(query, unicode): query = query.encode(charset) matched = INSERT_VALUES.match(query) @@ -221,7 +224,7 @@ values = matched.group('values') try: - sql_params = [ values % connection.literal(arg) for arg in args ] + sql_params = [ values % self.connection.literal(arg) for arg in args ] except TypeError, msg: if msg.args[0] in ("not enough arguments for format string", "not all arguments converted"): @@ -273,11 +276,11 @@ disconnected. """ - connection = self._get_db() - charset = connection.character_set_name() + db = self._get_db() + charset = self.connection.character_set_name() for index, arg in enumerate(args): query = "SET @_%s_%d=%s" % (procname, index, - connection.literal(arg)) + self.connection.literal(arg)) if isinstance(query, unicode): query = query.encode(charset) self._query(query) @@ -297,7 +300,7 @@ def _do_query(self, query): """Low-levey query wrapper. Overridden by MixIns.""" connection = self._get_db() - self._last_executed = query + self._executed = query connection.query(query) self._do_get_result() return self.rowcount