Ejemplo n.º 1
0
 def add(cls, udl, table_name=None):
     cursor = None
     table_id = None
     if udl is not None and isinstance(udl, AbsUserDirectLines):
         try:
             count = cls.count(udl, table_name)
             if count > 0:
                 table_id = count
             else:
                 cursor = db_conn.execute('''insert into ''' + table_name +
                                          ''' (svn_user_id,svn_url_info_id,Lines_of_Code,Changes,Lines_per_Change,
                                          Directory,start_date,end_date,week,year)
                                          values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)''',
                                          (udl.svn_user_id, udl.svn_url_info_id, udl.lines_of_code,
                                           udl.changes, udl.lines_per_change, udl.directory,
                                           udl.start_date, udl.end_date,
                                           udl.week, udl.year))
                 table_id = cursor.lastrowid
                 db_conn.commit()
         except IntegrityError:
             db_conn.rollback()
         finally:
             if cursor:
                 cursor.close()
     return table_id
Ejemplo n.º 2
0
 def add(cls, svn_url):
     svn_url_info = cls.get_by_svn_url(svn_url)
     if svn_url_info is None:
         cursor = db_conn.execute("""insert into svn_url_info (svn_url) values(%s)""", (svn_url,))
         db_conn.commit()
         cursor.close()
         svn_url_info = cls.get_by_svn_url(svn_url)
     return svn_url_info
Ejemplo n.º 3
0
 def add(cls, svn_user=None):
     cursor = None
     user = None
     try:
         if svn_user:
             user = cls.get_by_svn_user(svn_user)
         if user is None:
             cursor = db_conn.execute("""INSERT INTO svn_users (svn_user)  VALUES (%s)""", (svn_user,))
             user_id = cursor.lastrowid
             db_conn.commit()
             user = cls.get(user_id)
     except IntegrityError:
         db_conn.rollback()
     finally:
         if cursor:
             cursor.close()
     return user