def get_questions_answers(user_id):
        args = {'questioner_id': user_id}
        query = "SELECT * FROM questions q LEFT JOIN answers a ON a.question_id = q.id WHERE q.questioner_id = %(questioner_id)s"
        res = connection.select_query(query, args)
        return res
def check_user(email):
        args = {'email':email}
        query = "SELECT id FROM users WHERE email = %(email)s"
        res = connection.select_query(query, args)
        return res if res else None
def get_user_id(username):
    """Convenience method to look up the id for a username."""
    args = {'name' : username}
    query = "SELECT id FROM users WHERE name = %(name)s"
    rv = connection.select_query(query, args)
    return rv if rv else None
def get_user(username):
        args = {'name' : username}
        query = "SELECT * FROM users WHERE name = %(name)s"
        user = connection.select_query(query, args)
        return user if user else None