diff --git a/mylib/pgsql.py b/mylib/pgsql.py index 77cf5fd..84375d7 100644 --- a/mylib/pgsql.py +++ b/mylib/pgsql.py @@ -180,6 +180,10 @@ class PgDB: # SQL helpers # + @staticmethod + def format_param(param): + return '%({0})s'.format(param) + @classmethod def _combine_params(cls, params, to_add=None, **kwargs): if to_add: @@ -241,7 +245,7 @@ class PgDB: idx += 1 cls._combine_params(params, {param: value}) sql_where_clauses.append( - '"{field}" = %({param})s'.format(field=field, param=param) + '"{field}" = {param}'.format(field=field, param=cls.format_param(param)) ) return ( (" %s " % where_op).join(sql_where_clauses), @@ -282,7 +286,7 @@ class PgDB: self._quote_table_name(table), '", "'.join(values.keys()), ", ".join([ - '%({0})s'.format(key) + self.format_param(key) for key in values ]) ) @@ -302,7 +306,7 @@ class PgDB: sql = 'UPDATE {0} SET {1}'.format( self._quote_table_name(table), ", ".join([ - '"{0}" = %({0})s'.format(key) + '"{0}" = {1}'.format(key, self.format_param(key)) for key in values ]) )