Steps to create a postgres database and deply a Python app to Heroku
pipenv install gunicorn
or
pip install gunicorn
https://devcenter.heroku.com/articles/heroku-cli
heroku login
heroku create appname
heroku addons:create heroku-postgresql:hobby-dev --app appname
heroku config --app appname
# Add to your app
touch Procfile
# Add this
web: gunicorn app:app
pip freeze > requirements.txt
touch runtime.txt
# Add this
python-3.7.2
git init
git add . && git commit -m 'Deploy'
heroku git:remote -a appname
git push heroku master
heroku run python
>>> from app import db
>>> db.create_all()
>>>exit()
heroku open
When I tried to create postgresql table on heroku python cli this error happened and won't let me create the table.. any help appreciated..
Traceback (most recent call last):
File "", line 1, in
File "/app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/init.py", line 1094, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/init.py", line 1086, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/init.py", line 1017, in get_engine
return connector.get_engine()
File "/app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/init.py", line 594, in get_engine
self._engine = rv = self._sa.create_engine(sa_url, options)
File "/app/.heroku/python/lib/python3.9/site-packages/flask_sqlalchemy/init.py", line 1027, in create_engine
return sqlalchemy.create_engine(sa_url, **engine_opts)
File "", line 2, in create_engine
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
return fn(*args, **kwargs)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine
entrypoint = u._get_entrypoint()
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/url.py", line 653, in _get_entrypoint
cls = registry.load(name)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 341, in load
raise exc.NoSuchModuleError(
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres