Exemplo n.º 1
0
    def mq_query(s, l):
        """ Multiple Quiet Query: execute a multiple, quiet query."""

        Speaker.log_debug("Executing Massive Query...")

        DbOne._safe_execute(DbOne._mqquery, s, l)

        if not DbOne.trans_level:
            DbOne._commit()
Exemplo n.º 2
0
    def mq_query(self, s, l):
        """ Multiple Quiet Query: execute a multiple quiet query."""

        Speaker.log_debug("%s: Executing Massive Query...", 
                        INF_COL(self.session_name))

        res= self._safe_execute(self._mqquery, s, l)
        # len(l) - 1: because a query is added by safe_execute
        self._queries_n+= len(l) - 1
Exemplo n.º 3
0
    def mg_query(s, l):
        """ Multiple Get Query: execute a multiple, get query."""

        Speaker.log_debug("Executing Massive Query...")

        res= DbOne._safe_execute(DbOne._mgquery, s, l)

        if not DbOne.trans_level:
            DbOne._commit()

        return res
Exemplo n.º 4
0
    def rollback():
        if not DbOne.trans_level:
            Speaker.log_warning(
                    "Nothing to rollback: "
                    "nested rollback?")
            return

        Speaker.log_debug("Rollbacking queries... (trans level= %s) ", 
                DbOne.trans_level)
        DbOne._rollback()
        DbOne.trans_level= 0

        return
Exemplo n.º 5
0
    def commit():
        lvl= DbOne.trans_level
        if not lvl:
            Speaker.log_warning(
                    "Nothing to commit: "
                    "nested commit?")
            return

        if lvl== 1:
            DbOne._commit()
            DbOne.trans_level-= 1
            Speaker.log_debug(
                    "Queries committed.")
            return

        DbOne.trans_level-= 1
        Speaker.log_debug(
                "Decremented transaction: now %s",
                INF_COL(DbOne.trans_level))
        return
Exemplo n.º 6
0
    def _do_query(s, ftr= None, result= True):

        execattr= result and DbOne._gquery or DbOne._qquery

        if not ftr:
            d= {}
        elif isinstance(ftr, MoFilter):
            s, d= ftr.return_ftrqry(s)
        elif isinstance(ftr, dict):
            d= ftr
        elif isinstance(ftr, tuple):
            d= ftr
        else:
            Speaker.log_int_raise('Invalid Filter Type: %s', 
                    ERR_COL(type(ftr)))

        # logging info...
        mogrify= getattr(DbOne._iface_instance, '_mogrify', None)
        try:
            Speaker.log_debug("QSQL- %s", mogrify(s, d))
        except:
            Speaker.log_debug("QSQL- %s, Filter= %s", s, d)

        return DbOne._safe_execute(execattr, s, d)
Exemplo n.º 7
0
 def beginTrans():
     DbOne.trans_level+= 1
     Speaker.log_debug(
             'Incremented transaction level: %s', 
             INF_COL(DbOne.trans_level))