def get_articles(indices):
"""
INPUT: list of integers corresponding to
'index' column values of desired articles in database
OUTPUT: list of dictionaries, each dictionary
corresponding to an article
"""
with conn.cursor(cursor_factory=DictCursor) as cur:
query = "SELECT * FROM articles \
WHERE index IN %s \
ORDER BY last_submitted DESC"
cur.execute(query, (tuple(indices),))
articles = cur.fetchall()
return articles
评论列表
文章目录