1 | in djangoe/core/db/backends/mysql.py:
|
---|
2 | @@ -21,6 +21,34 @@
|
---|
3 | FIELD_TYPE.TIME: typecasts.typecast_time,
|
---|
4 | })
|
---|
5 |
|
---|
6 | +#TODO(lambert): merge with latest django code when it comes out
|
---|
7 | +class MysqlDebugWrapper:
|
---|
8 | + def __init__(self, cursor):
|
---|
9 | + self.cursor = cursor
|
---|
10 | +
|
---|
11 | + def execute(self, sql, params=[]):
|
---|
12 | + try:
|
---|
13 | + result = self.cursor.execute(sql, params)
|
---|
14 | + except Database.Warning, w:
|
---|
15 | + self.cursor.execute("show warnings")
|
---|
16 | + raise Database.Warning, "%s: %s" % (w,self.cursor.fetchall())
|
---|
17 | + return result
|
---|
18 | +
|
---|
19 | + def executemany(self, sql, param_list):
|
---|
20 | + try:
|
---|
21 | + result = self.cursor.executemany(sql, param_list)
|
---|
22 | + except Database.Warning:
|
---|
23 | + self.cursor.execute("show warnings")
|
---|
24 | + raise Database.Warning, "%s: %s" % (w,self.cursor.fetchall())
|
---|
25 | + return result
|
---|
26 | +
|
---|
27 | + def __getattr__(self, attr):
|
---|
28 | + if self.__dict__.has_key(attr):
|
---|
29 | + return self.__dict__[attr]
|
---|
30 | + else:
|
---|
31 | + return getattr(self.cursor, attr)
|
---|
32 | +
|
---|
33 | +
|
---|
34 | class DatabaseWrapper:
|
---|
35 | def __init__(self):
|
---|
36 | self.connection = None
|
---|
37 | @@ -32,7 +60,8 @@
|
---|
38 | self.connection = Database.connect(user=DATABASE_USER, db=DATABASE_NAME,
|
---|
39 | passwd=DATABASE_PASSWORD, host=DATABASE_HOST, conv=django_conversions)
|
---|
40 | if DEBUG:
|
---|
41 | - return base.CursorDebugWrapper(self.connection.cursor(), self)
|
---|
42 | + #TODO(lambert): merge with latest django code when it comes out
|
---|
43 | + return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self)
|
---|
44 | return self.connection.cursor()
|
---|
45 |
|
---|
46 | def commit(self):
|
---|