コード例 #1
0
ファイル: hb_dao.py プロジェクト: dauanaana/Aulas_Python
    def buscar_por_id(self, id):
        comando_sql_buscar_id = f"""SELECT 
                                s.nome, 
                                bd.nome,
                                bd.id, 
                                f.nome,
                                f.id, 
                                l.nome,
                                l.id, 
                                s.id 
                                FROM squads as s 
                                JOIN banco as bd
                                ON s.fk_bd = bd.id 
                                JOIN framework as f 
                                ON s.fk_framework = f.id 
                                JOIN linguagens as l 
                                ON s.fk_linguagem = l.id
                                WHERE s.id = {id}"""

        l = super().buscar_por_id(comando_sql_buscar_id)
        bd = BD(l[1], l[2])
        frame = Framework(l[3], l[4])
        ling = Linguagem(l[5], l[6])
        squad = HB(l[0], bd.__dict__(), frame.__dict__(), ling.__dict__(),
                   l[7])
        return squad.__dict__()
コード例 #2
0
ファイル: hb_dao.py プロジェクト: dauanaana/Aulas_Python
    def listar(self, id=None):
        lista_squad = []
        comando_sql_listar = """SELECT 
                                s.nome, 
                                bd.nome,
                                bd.id, 
                                f.nome,
                                f.id, 
                                l.nome,
                                l.id, 
                                s.id 
                                FROM squads as s 
                                JOIN banco as bd
                                ON s.fk_bd = bd.id 
                                JOIN framework as f 
                                ON s.fk_framework = f.id 
                                JOIN linguagens as l 
                                ON s.fk_linguagem = l.id"""

        tupla_cads = super().listar(comando_sql_listar)
        for l in tupla_cads:
            bd = BD(l[1], l[2])
            frame = Framework(l[3], l[4])
            ling = Linguagem(l[5], l[6])
            squad = HB(l[0], bd.__dict__(), frame.__dict__(), ling.__dict__(),
                       l[4])
            lista_squad.append(squad.__dict__())
        return lista_squad