I'm using FastAPI and currently I return a csv which I read from SQL server with pandas. (pd.read_sql()) However the csv is quite big for the browser and I want to return it with a File response: https://fastapi.tiangolo.com/advanced/custom-response/ (end of the page). I cannot seem to do this without first writing it to a csv file which seems slow and will clutter the filesystem with csv's on every request.
So my questions way, is there way to return a FileResponse from a sql database or pandas dataframe.
And if not, is there a way to delete the generated csv files, after it has all been read by the client?
Thanks for your help!
Kind regards,
Stephan