How do I execute a python script on Heroku?
csv, django, heroku, python
Solution
Heroku doesn't give you write permissions anywhere on your dyno (the only files it writes are the ones it checks out from your master branch when you push an update, and any dependencies). You'll have to upload your output to S3, save it to the log, or find some other delivery mechanism (email?)
Problem
I have a python script which I only need to run once (I don't want to have to commit it to the repo to send to the Cedar instance). The Script aggregates data over my Django models and outputs a .csv file. Normally in AWS, I would `scp` the script to the server, `manage.py shell < script.py`, and `scp` the produced .csv back to my machine. I understand Heroku file systems are ephemeral, but is there a way to retrieve produced files on Heroku servers without uploading them to S3? Here's my best shot: ``` cat script.py | heroku run manage.py shell --app appname ``` Works for a one line script, but not with line breaks. Also, the above script will only produce command line output, not return a .csv file.