Esempio n. 1
0
 def get_one_by_id(self, id):
     if id == None or id < 0:
         return None
     self.cursor.execute("SELECT * from projekt.chapter where id=%d ;" % id)
     records_chapter = self.cursor.fetchone()
     if records_chapter == None:
         return None
     now_chapter = Chapter()
     now_chapter.id = records_chapter[0]
     now_chapter.chapter_name = records_chapter[1]
     now_chapter.edited_date = records_chapter[2]
     return now_chapter
Esempio n. 2
0
 def get_all(self):
     self.cursor.execute("SELECT * from projekt.chapter ;")
     records_chapter = self.cursor.fetchall()
     if records_chapter != None:
         chapter_list = []
         for chapter in records_chapter:
             now_chapter = Chapter()
             now_chapter.id = chapter[0]
             now_chapter.chapter_name = chapter[1]
             now_chapter.edited_date = chapter[2]
             chapter_list.append(now_chapter)
         return chapter_list
     else:
         return None