Code Room
Code reviewMedium
Question
Review this Python data-access code that loads authors for a batch of posts (raw SQL, no ORM).
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
def attach_authors(conn, posts): cur = conn.cursor() for post in posts: cur.execute( "SELECT id, name, avatar FROM authors WHERE id = %s", (post["author_id"],)) a = cur.fetchone() post["author"] = {"name": a[1], "avatar": a[2]} return postsRun or narrate your approach, then ask the coach.