def get_user_info(db, user_id, test=False):
    """Fetch user info from database."""
    user_id = int(user_id)
    cur = db.cursor()
    user_info = None
    if test:
        user_info = cur.execute(
            'SELECT * FROM users WHERE user_id=?', (user_id, )).fetchone()
    else:
        cur.execute("SELECT * FROM users WHERE user_id=%s", (user_id, ))
        user_info = cur.fetchone()
    column_names = tuple(description[0] for description in cur.description)
    cur.close()
    if user_info is None:
        return None
    return dict(zip(column_names, user_info))