Project

General

Profile

« Previous | Next » 

Revision 2671

sql.py: DbConn: Added print_notices() and call it after running a query

View differences:

lib/sql.py
162 162
        self.__db = None
163 163
        self.query_results = {}
164 164
        self._savepoint = 0
165
        self._notices_seen = set()
165 166
    
166 167
    def __getattr__(self, name):
167 168
        if name == '__dict__': raise Exception('getting __dict__')
......
277 278
        if self.can_mogrify(): return self.db.cursor().mogrify(query, params)
278 279
        else: raise NotImplementedError("Can't mogrify query")
279 280
    
281
    def print_notices(self):
282
        for msg in self.db.notices:
283
            if msg not in self._notices_seen:
284
                self._notices_seen.add(msg)
285
                self.log_debug(msg, level=2)
286
    
280 287
    def run_query(self, query, params=None, cacheable=False, log_level=2,
281 288
        debug_msg_ref=None):
282 289
        '''
......
314 321
            # Run query
315 322
            cur.execute(query, params)
316 323
        finally:
324
            self.print_notices()
317 325
            if self.debug and debug_msg_ref != None: # return after running
318 326
                debug_msg_ref[0] = log_msg(str(get_cur_query(cur, query,
319 327
                    params)))

Also available in: Unified diff