mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
Reintroduced support for parameter dictionaries when using the PostgreSQL
psycopg1 backend directly. Refs #3322. Based on a patch from kurtiss@meetro.com. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5227 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9de774aad8
commit
2aa9d45c01
1
AUTHORS
1
AUTHORS
@ -141,6 +141,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Bruce Kroeze <http://coderseye.com/>
|
||||
Joseph Kocherhans
|
||||
konrad@gwu.edu
|
||||
kurtiss@meetro.com
|
||||
lakin.wecker@gmail.com
|
||||
Stuart Langridge <http://www.kryogenix.org/>
|
||||
Nicola Larosa <nico@teknico.net>
|
||||
|
@ -40,11 +40,21 @@ class UnicodeCursorWrapper(object):
|
||||
self.cursor = cursor
|
||||
self.charset = charset
|
||||
|
||||
def format_params(self, params):
|
||||
if isinstance(params, dict):
|
||||
result = {}
|
||||
charset = self.charset
|
||||
for key, value in params.items():
|
||||
result[smart_str(key, charset)] = smart_str(value, charset)
|
||||
return result
|
||||
else:
|
||||
return tuple([smart_str(p, self.charset, True) for p in params])
|
||||
|
||||
def execute(self, sql, params=()):
|
||||
return self.cursor.execute(smart_str(sql, self.charset), [smart_str(p, self.charset, True) for p in params])
|
||||
return self.cursor.execute(smart_str(sql, self.charset), self.format_params(params))
|
||||
|
||||
def executemany(self, sql, param_list):
|
||||
new_param_list = [tuple([smart_str(p, self.charset) for p in params]) for params in param_list]
|
||||
new_param_list = [self.format_params(params) for params in param_list]
|
||||
return self.cursor.executemany(sql, new_param_list)
|
||||
|
||||
def __getattr__(self, attr):
|
||||
|
Loading…
x
Reference in New Issue
Block a user