コード例 #1
0
ファイル: processa_sql.py プロジェクト: feliphebueno/py_watch
class processaSql:

    con = None

    def __init__(self):
        self.con = Conexao()
        return

    def getDadosPullRequestSql(self, id):
        qb = self.con.qb('prod_t1')
        return qb.table('repositorio_pull').where('repositorioPullId', id)

    def getContributorSql(self, login):
        qb = self.con.qb('prod_t1')
        return qb.table('contributor').where('contributorLogin', login)

    def getRepositorioSql(self, id):
        qb = self.con.qb('prod_t1')
        return qb.table('repositorio').where('repositorioId', id)

    def getCommitSql(self, sha):
        qb = self.con.qb('prod_t1')
        return qb.table('repositorio_branch_commit').where('repositorioBranchCommitSha', sha)

    def getBranchSql(self, name):
        qb = self.con.qb('prod_t1')
        return qb.table('repositorio_branch').where('repositorioBranchNome', name)
コード例 #2
0
ファイル: crud_util.py プロジェクト: feliphebueno/py_watch
class CrudUtil():

    con = None

    def __init__(self, link = 'padrao'):
        self.con = Conexao(link)

    def insert(self, tabela, camposValores):
        try:
            self.con.qb().begin_transaction()
            id = self.con.qb().table(tabela).insert_get_id(camposValores)
            self.con.qb().commit()
            return id
        except Exception as e:
            self.con.qb().rollback()
            raise Exception("Database transaction failed. Details: "+ str(e))

    def update(self, tabela, where, camposValores):
        try:
            self.con.qb().begin_transaction()
            id = self.con.qb().table(tabela).where(where).update(camposValores)
            self.con.qb().commit()
            return id
        except Exception as e:
            self.con.qb().rollback()
            raise Exception("Database transaction failed. Details: " + str(e))

    def delete(self, tabela, where):
        try:
            self.con.qb().begin_transaction()
            id = self.con.qb().table(tabela).where(where).delete()
            self.con.qb().commit()
            return id
        except Exception as e:
            self.con.qb().rollback()
            raise Exception("Database transaction failed. Details: " + str(e))