def METHOD_NAME(directory):
    curs = connection.cursor()
    for fn, q, order in _querymap:
        with open(os.path.join(directory, fn), 'w') as f:
            curs.copy_expert("COPY ({} ORDER BY {}) TO STDOUT".format(q, order), f)