Django

Code

Changeset 5227

Show
Ignore:
Timestamp:
05/14/07 05:48:24 (1 year ago)
Author:
mtredinnick
Message:

Reintroduced support for parameter dictionaries when using the PostgreSQL
psycopg1 backend directly. Refs #3322. Based on a patch from kurtiss@meetro.com.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/AUTHORS

    r5214 r5227  
    142142    Joseph Kocherhans 
    143143    konrad@gwu.edu 
     144    kurtiss@meetro.com 
    144145    lakin.wecker@gmail.com 
    145146    Stuart Langridge <http://www.kryogenix.org/> 
  • django/branches/unicode/django/db/backends/postgresql/base.py

    r5214 r5227  
    4141        self.charset = charset 
    4242 
     43    def format_params(self, params): 
     44        if isinstance(params, dict): 
     45            result = {} 
     46            charset = self.charset 
     47            for key, value in params.items(): 
     48                result[smart_str(key, charset)] = smart_str(value, charset) 
     49            return result 
     50        else: 
     51            return tuple([smart_str(p, self.charset, True) for p in params]) 
     52 
    4353    def execute(self, sql, params=()): 
    44         return self.cursor.execute(smart_str(sql, self.charset), [smart_str(p, self.charset, True) for p in params]
     54        return self.cursor.execute(smart_str(sql, self.charset), self.format_params(params)
    4555 
    4656    def executemany(self, sql, param_list): 
    47         new_param_list = [tuple([smart_str(p, self.charset) for p in params]) for params in param_list] 
     57        new_param_list = [self.format_params(params) for params in param_list] 
    4858        return self.cursor.executemany(sql, new_param_list) 
    4959