import io


def image_models_to_csv(images: list):
    """
    Given a list of Image models, convert the result to an in-memory CSV. This allows faster transfers to the database
    via COPY FROM.
    """
    csv_images = io.StringIO()
    for image in images:
        row = '\t'.join(list(image.values())) + '\n'

        csv_images.write(row)
    csv_images.seek(0)
    return csv_images