(self, curs, sql, args, quiet = False, prefix = None)
return (ok, rows)
Internal tool: Run SQL on cursor.
Internal tool: Run SQL on cursor.
Internal tool : Run SQL on cursor .
def _exec_cmd(self, curs, sql, args, quiet = False, prefix = None):
        """Internal tool: Run SQL on cursor."""
        if self.options.verbose:
            self.log.debug("exec_cmd: %s" % skytools.quote_statement(sql, args))

        _pfx = ""
        if prefix:
            _pfx = "[%s] " % prefix
        curs.execute(sql, args)
        ok = True
        rows = curs.fetchall()
        for row in rows:
            try:
                code = row['ret_code']
                msg = row['ret_note']
            except KeyError:
                self.log.error("Query does not conform to exec_cmd API:")
                self.log.error("SQL: %s" % skytools.quote_statement(sql, args))
                self.log.error("Row: %s" % repr(row.copy()))
                sys.exit(1)
            level = code / 100
            if level == 1:
                self.log.debug("%s%d %s" % (_pfx, code, msg))
            elif level == 2:
                if quiet:
                    self.log.debug("%s%d %s" % (_pfx, code, msg))
                else:
                    self.log.info("%s%s" % (_pfx, msg,))
            elif level == 3:
                self.log.warning("%s%s" % (_pfx, msg,))
            else:
                self.log.error("%s%s" % (_pfx, msg,))
                self.log.debug("Query was: %s" % skytools.quote_statement(sql, args))
                ok = False
        return (ok, rows)
def _exec_cmd ( self , curs , sql , args , quiet = False , prefix = None ) : if self . options . verbose : self . log . debug ( "exec_cmd: %s" % skytools . quote_statement ( sql , args ) ) _pfx = "" if prefix : _pfx = "[%s] " % prefix curs . execute ( sql , args ) ok = True rows = curs . fetchall ( ) for row in rows : try : code = row [ 'ret_code' ] msg = row [ 'ret_note' ] except KeyError : self . log . error ( "Query does not conform to exec_cmd API:" ) self . log . error ( "SQL: %s" % skytools . quote_statement ( sql , args ) ) self . log . error ( "Row: %s" % repr ( row . copy ( ) ) ) sys . exit ( 1 ) level = code / 100 if level == 1 : self . log . debug ( "%s%d %s" % ( _pfx , code , msg ) ) elif level == 2 : if quiet : self . log . debug ( "%s%d %s" % ( _pfx , code , msg ) ) else : self . log . info ( "%s%s" % ( _pfx , msg , ) ) elif level == 3 : self . log . warning ( "%s%s" % ( _pfx , msg , ) ) else : self . log . error ( "%s%s" % ( _pfx , msg , ) ) self . log . debug ( "Query was: %s" % skytools . quote_statement ( sql , args ) ) ok = False return ( ok , rows )