コード例 #1
0
 def __fetch_to_object(self, fetchresult, return_one=False):
     """
     fetch[0]: id_championnat
     fetch[1]: id_equipe
     fetch[2]: id_equipe_exterieur
     fetch[3]: id_match
     fetch[4]: date_match
     fetch[5]: commentaire_match
     fetch[6]: isplayed_match
     :param fetchresult:
     :param return_one:
     :return:
     """
     liste = []
     try:
         if len(fetchresult) > 0:
             for fetch in fetchresult:
                 obj = Match(fetch[1],
                             fetch[2],
                             fetch[4],
                             fetch[5],
                             fetch[6])
                 obj.id = fetch[3]
                 liste.append(obj)
             return liste if not return_one else liste[0]
         else:
             return None
     except Exception as ex:
         DAOException(self, ex)
コード例 #2
0
 def __fetch_to_object(self, fetchresult, return_one=False):
     """
     fetch[0]: id_championnat
     fetch[1]: id_but
     fetch[2]: commentaire_but
     fetch[3]: id_joueur_assistance
     fetch[4]: id_joueur
     fetch[5]: id_match
     fetch[6]: id_equipe
     :param fetchresult:
     :return:
     """
     liste = []
     try:
         if len(fetchresult) > 0:
             for fetch in fetchresult:
                 obj = Goals(fetch[4], fetch[5], fetch[6], fetch[2],
                             fetch[3])
                 obj.id = fetch[1]
                 liste.append(obj)
             return liste if not return_one else liste[0]
         else:
             return None
     except Exception as ex:
         DAOException(self, ex)
コード例 #3
0
ファイル: abstractdao.py プロジェクト: ChatNoir76/Championnat
 def _insert(self, request, parameters):
     with self._conn as conn:
         try:
             c = conn.cursor()
             c.execute(request, parameters)
             conn.commit()
             return c.lastrowid
         except sqlite3.Error as ex:
             conn.rollback()
             DAOException(self, ex)
コード例 #4
0
ファイル: abstractdao.py プロジェクト: ChatNoir76/Championnat
 def _delete(self, request, obj_id):
     with self._conn as conn:
         try:
             c = conn.cursor()
             c.execute(request, obj_id)
             conn.commit()
             return True
         except Exception as ex:
             conn.rollback()
             DAOException(self, ex)
             return False
コード例 #5
0
ファイル: abstractdao.py プロジェクト: ChatNoir76/Championnat
 def _update(self, request, parameters):
     with self._conn as conn:
         try:
             c = conn.cursor()
             c.execute(request, parameters)
             conn.commit()
             return True
         except Exception as ex:
             conn.rollback()
             DAOException(self, ex)
             return False
コード例 #6
0
ファイル: abstractdao.py プロジェクト: ChatNoir76/Championnat
 def _read(self, request, parameters=None):
     with self._conn as conn:
         try:
             c = conn.cursor()
             if parameters is None:
                 c.execute(request)
             else:
                 c.execute(request, parameters)
             return c.fetchall()
         except Exception as ex:
             DAOException(self, ex)
コード例 #7
0
 def __fetch_to_object(self, fetchresult, return_one=False):
     liste = []
     try:
         if len(fetchresult) > 0:
             for fetch in fetchresult:
                 obj = Competition(fetch[1], fetch[2], fetch[3], fetch[4],
                                   fetch[5], fetch[6])
                 obj.id = fetch[0]
                 liste.append(obj)
             return liste if not return_one else liste[0]
         else:
             return None
     except Exception as ex:
         DAOException(self, ex)
コード例 #8
0
ファイル: dao_team.py プロジェクト: ChatNoir76/Championnat
 def insert(self, o_team):
     if isinstance(o_team, Team):
         with self._conn as conn:
             try:
                 c = conn.cursor()
                 param_rq1 = [o_team.name,
                              o_team.comment]
                 c.execute(R_INSERT1, param_rq1)
                 index = c.lastrowid
                 param_rq2 = [index,
                              o_team.id_competition]
                 c.execute(R_INSERT2, param_rq2)
                 conn.commit()
                 o_team.id = index
             except Exception as ex:
                 conn.rollback()
                 DAOException(self, ex)
コード例 #9
0
    def insert(self, o_match):
        if isinstance(o_match, Match):
            with self._conn as conn:
                try:
                    c = conn.cursor()
                    lparam = [o_match.datetime,
                              o_match.comment,
                              o_match.isplayed]
                    c.execute(R_INSERT, lparam)
                    index = c.lastrowid

                    pcalendrier = [o_match.idteam_home,
                                   index,
                                   o_match.idteam_outside]
                    c.execute(R_INSERT2, pcalendrier)
                    conn.commit()
                    o_match.id = index
                except Exception as ex:
                    conn.rollback()
                    DAOException(self, ex)