Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python manage.py deploy ... error with db #36

Open
KelleClark opened this issue Oct 28, 2021 · 0 comments
Open

python manage.py deploy ... error with db #36

KelleClark opened this issue Oct 28, 2021 · 0 comments

Comments

@KelleClark
Copy link

KelleClark commented Oct 28, 2021

on a MacOS Mojave 10.14.6

I followed Readme:
postgreSQL 9.6 (running and created database circulate)
venv activated
installed requirements.txt

python manage.py deploy --> error:
(venv) (base) Kelles-MacBook-Air-2:circleci-demo-python-flask kelleclark$ python manage.py deploy
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "manage.py", line 83, in
manager.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_script/init.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_script/init.py", line 383, in handle
res = handle(*args, **config)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_script/commands.py", line 216, in call
return self.run(*args, **kwargs)
File "manage.py", line 76, in deploy
Role.insert_roles()
File "/Users/kelleclark/Documents/CI_practice/circleci-demo-python-flask/app/models.py", line 42, in insert_roles
role = Role.query.filter_by(name=r).first()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3214, in first
ret = list(self[0:1])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3006, in getitem
return list(res)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3316, in iter
return self._execute_and_instances(context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3341, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "roles" does not exist
LINE 2: FROM roles
^

[SQL: SELECT roles.id AS roles_id, roles.name AS roles_name, roles."default" AS roles_default, roles.permissions AS roles_permissions
FROM roles
WHERE roles.name = %(name_1)s
LIMIT %(param_1)s]
[parameters: {'name_1': 'Moderator', 'param_1': 1}]
(Background on this error at: http://sqlalche.me/e/f405)

What I did ...
It seemed like the table for roles hadnt been created...and I saw that in the testing they created some data by using

db.create_all()

so in manage.py, I added db.create:
@manager.command
def deploy():
"""Run deployment tasks."""
from flask_migrate import upgrade
from app.models import Role, User
db.create_all()

Now seems to be ok....

(venv) (base) Kelles-MacBook-Air-2:circleci-demo-python-flask kelleclark$ python manage.py deploy
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
(venv) (base) Kelles-MacBook-Air-2:circleci-demo-python-flask kelleclark$ python manage.py runserver

  • Serving Flask app "app" (lazy loading)
  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 174-714-230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant