Changeset 721 for trunk/pg.py


Ignore:
Timestamp:
Jan 12, 2016, 7:58:04 AM (4 years ago)
Author:
cito
Message:

Use query parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pg.py

    r720 r721  
    423423        """
    424424        s = _split_parts(cl)
    425         if len(s) > 1:  # name already qualfied?
     425        if len(s) > 1:  # name already qualified?
    426426            # should be database.schema.table or schema.table
    427427            if len(s) > 3:
     
    664664            " JOIN pg_attribute a ON a.attrelid = r.oid"
    665665            " JOIN pg_type t ON t.oid = a.atttypid"
    666             " WHERE s.nspname = '%s' AND r.relname = '%s'"
     666            " WHERE s.nspname = $1 AND r.relname = $2"
    667667            " AND (a.attnum > 0 OR a.attname = 'oid')"
    668668            " AND NOT a.attisdropped") % (
    669                 '::regtype' if self._regtypes else '', cl[0], cl[1])
    670         q = self.db.query(q).getresult()
     669                '::regtype' if self._regtypes else '',)
     670        q = self.db.query(q, cl).getresult()
    671671
    672672        if self._regtypes:
     
    722722            return self._privileges[(qcl, privilege)]
    723723        except KeyError:
    724             q = "SELECT has_table_privilege('%s', '%s')" % (qcl, privilege)
    725             ret = self.db.query(q).getresult()[0][0] == self._make_bool(True)
     724            q = "SELECT has_table_privilege($1, $2)"
     725            q = self.db.query(q, (qcl, privilege))
     726            ret = q.getresult()[0][0] == self._make_bool(True)
    726727            self._privileges[(qcl, privilege)] = ret
    727728            return ret
Note: See TracChangeset for help on using the changeset viewer.