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
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
def get_all_poems(self): sql = "SELECT * FROM {};".format(self.poem_model.table_name) poem_ids = query(self.db.cursor, sql) return poem_ids
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])
def get_all_ids(self): ids = query(self.db.cursor, self.sql_select_ids()) return ids
def get_count(self): count = query(self.db.cursor, self.sql_count(), "one") return int(count[0])
def get_artist_info(self, artist_id): result = query(self.db.cursor, self.sql_get_artist_info(artist_id), "one") return result
def get_artist_id(self, image_id): result = query(self.db.cursor, self.sql_get_artists_id(image_id), "one") return result[0]
def get_image_id(self, image_filename): result = query(self.db.cursor, self.sql_image_id(image_filename), "one") return result[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