magic-removal: fixed #1475 - debug mode now logs failsed queries, as well (thanks, cmlenz)

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2500 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2006-03-07 17:57:15 +00:00
parent b1e6e88495
commit 3d64e7e63f
1 changed files with 16 additions and 14 deletions

View File

@ -8,23 +8,25 @@ class CursorDebugWrapper:
def execute(self, sql, params=[]): def execute(self, sql, params=[]):
start = time() start = time()
result = self.cursor.execute(sql, params) try:
stop = time() return self.cursor.execute(sql, params)
self.db.queries.append({ finally:
'sql': sql % tuple(params), stop = time()
'time': "%.3f" % (stop - start), self.db.queries.append({
}) 'sql': sql % tuple(params),
return result 'time': "%.3f" % (stop - start),
})
def executemany(self, sql, param_list): def executemany(self, sql, param_list):
start = time() start = time()
result = self.cursor.executemany(sql, param_list) try:
stop = time() return self.cursor.executemany(sql, param_list)
self.db.queries.append({ finally:
'sql': 'MANY: ' + sql + ' ' + str(tuple(param_list)), stop = time()
'time': "%.3f" % (stop - start), self.db.queries.append({
}) 'sql': 'MANY: ' + sql + ' ' + str(tuple(param_list)),
return result 'time': "%.3f" % (stop - start),
})
def __getattr__(self, attr): def __getattr__(self, attr):
if self.__dict__.has_key(attr): if self.__dict__.has_key(attr):