0

I have an django app which create csv file from database queryset and send it to api as following

#create queryset
qs=Apple.objects.filter(args)
#create csv file 
with open('foo.csv','wb') as f:
    write(qs,f)
    res=requests.post(url,{'file':f})

I didnt list full code of creating csv from queryset because it isnt important for me. My focus is on csv file itself. I want to create csv, send it than destroy it. Because neccesity in csv file only that api where i send data receive data only in csv. And data which i put in csv have in my darabase. Currently after sending file i delete it by os.remove but i didnt like it. I was thinking about temporary file or any another solution

0 Answers0