def create_participation_for_project(self, creation_time, project, student): participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(1) with ParticipationMapper() as mapper: mapper.find_participation_of_project(project)
def create_participation(self, id, creation_time, project, student): """Einen Teilnahme anlegen""" participation = Participation() participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) participation.set_id(id) participation.set_id(1) with ParticipationMapper() as mapper: return mapper.insert(participation)
def find_all(self): result = [] cursor = self._cnx.cursor() cursor.execute( "SELECT id, creation_time, project, student FROM participation") tuples = cursor.fetchall() for (id, creation_time, project, student) in tuples: participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result.append(participation) self._cnx.commit() cursor.close() return result
def find_by_id(self, id): result = None cursor = self._cnx.cursor() command = "SELECT id, creation_time, project, student FROM participation WHERE id={}".format( id) cursor.execute(command) tuples = cursor.fetchall() if tuples[0] is not None: (id, creation_time, project, student) = tuples[0] participation = Participation() participation.set_id(id) participation.set_creation_time(creation_time) participation.set_project(project) participation.set_student(student) result = participation self._cnx.commit() cursor.close() return result