<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_value(stmt, args=(), default=None):
 """ Execute a query, returning the first value in the first row of the result set. If the query returns no result set, a default value is returned, which is `None` by default. """

    for row in query(stmt, args, TupleFactory):
        return row[0]
    return default