예제 #1
0
 def get_random_quote(self):
     quote_ids = self.get_all_ids()
     rand_num = random.randint(0, len(quote_ids) - 1)
     quote = query(self.db.cursor,
                   self.sql_quote_by_id(quote_ids[rand_num][0]))
     quote_text = quote[0][1]
     quote_author = quote[0][2]
     return quote_text, quote_author
예제 #2
0
 def get_author_by_id(self, auth_id):
     sql = "SELECT * FROM {} WHERE {} = {};".format(
         self.author_model.table_name, self.author_model.col_author_id,
         auth_id)
     author_rec = query(self.db.cursor, sql, "one")
     return author_rec
예제 #3
0
 def get_all_poems(self):
     sql = "SELECT * FROM {};".format(self.poem_model.table_name)
     poem_ids = query(self.db.cursor, sql)
     return poem_ids
예제 #4
0
 def get_poem_count(self):
     sql = "SELECT COUNT(*) FROM {};".format(self.poem_model.table_name)
     count = query(self.db.cursor, sql, "one")
     return int(count[0])
예제 #5
0
 def get_all_ids(self):
     ids = query(self.db.cursor, self.sql_select_ids())
     return ids
예제 #6
0
 def get_count(self):
     count = query(self.db.cursor, self.sql_count(), "one")
     return int(count[0])
예제 #7
0
파일: scifi.py 프로젝트: yTpo1/image_tagger
 def get_artist_info(self, artist_id):
     result = query(self.db.cursor, self.sql_get_artist_info(artist_id),
                    "one")
     return result
예제 #8
0
파일: scifi.py 프로젝트: yTpo1/image_tagger
 def get_artist_id(self, image_id):
     result = query(self.db.cursor, self.sql_get_artists_id(image_id),
                    "one")
     return result[0]
예제 #9
0
파일: scifi.py 프로젝트: yTpo1/image_tagger
 def get_image_id(self, image_filename):
     result = query(self.db.cursor, self.sql_image_id(image_filename),
                    "one")
     return result[0]
예제 #10
0
 def get_random_quote(self):
     quote_ids = self.get_all_ids()
     rand_num = random.randint(0, len(quote_ids) - 1)
     quote = query(self.db.cursor,
                   self.sql_quote_by_id(quote_ids[rand_num][0]))
     return quote