heroku備忘
【Python】PythonプログラムをHerokuにデプロイする方法 - Qiita
https://qiita.com/1-row/items/80f89c8ada2e61f04446
公式チュートリアル
https://devcenter.heroku.com/articles/getting-started-with-python#deploy-the-app
flaskの場合
仮想環境を作成
python3 -m venv myproject
cd myproject
pipでflaskとgunicornをinstall
最低限のapp.pyを作成
git init
git add .
git commit -m”1st commit”
heroku create “myapp191006”(リモートの紐づけもされる)
git push heroku master
heroku open
アプリをコマンドで削除する場合
heroku apps:destroy –app (app name)
datasetをpip installするときは,psycopg2もpip installする。
そうしないとエラーになる。
heroku pg:psql
で,そのディレクトリに紐付いたアプリに紐付いたデータベースに接続できる
sql文は,大文字でなければダメらしい
heroku pg:psql コマンドで接続できる。
公式サイトによると,以下で,ユーザーパスワードなどの接続情報が取得できる https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-python
import os
DATABASE_URL = os.environ['DATABASE_URL']