mohidex / flask-microblog

A full-featured blog application using Python Flask framework where an authenticated user can create a new post in markdown. A user can update and delete his/her post. A user can follow/unfollow other users and only see the post he/she following in his/her home page.
http://awesome-blogging.herokuapp.com/
MIT License
4 stars 1 forks source link

Hello, is there a more detailed deployment method? I don't know much about database configuration. #5

Closed a3vilc0de closed 3 years ago

a3vilc0de commented 3 years ago

Hello, is there a more detailed deployment method? I don't know much about database configuration.

mohidex commented 3 years ago

Hi Ppblibo, you can follow this blog if you want to deploy in heruko: https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xviii-deployment-on-heroku

a3vilc0de commented 3 years ago

Hello,I read the link you posted and learned a lot, but when I was deploying with ubuntu, the following error was prompted when I executed flask db upgrade.

image

image

a3vilc0de commented 3 years ago

[2021-02-16 02:41:19,006] INFO in init: Microblog startup INFO [alembic.runtime.migration] Context impl SQLiteImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade 3a5a5514500a -> 149feea4a7a8, empty message Traceback (most recent call last): File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context cursor, statement, parameters, context File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: table user already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/ubuntu/venv/bin/flask", line 11, in sys.exit(main()) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask/cli.py", line 966, in main cli.main(prog_name="python -m flask" if as_module else None) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask/cli.py", line 586, in main return super(FlaskGroup, self).main(args, kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 555, in invoke return callback(args, kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, *kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask/cli.py", line 426, in decorator return __ctx.invoke(f, args, kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/click/core.py", line 555, in invoke return callback(*args, kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask_migrate/cli.py", line 134, in upgrade _upgrade(directory, revision, sql, tag, x_arg) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask_migrate/init.py", line 95, in wrapped f(*args, kwargs) File "/home/ubuntu/venv/lib/python3.6/site-packages/flask_migrate/init.py", line 280, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/command.py", line 298, in upgrade script.run_env() File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/script/base.py", line 489, in run_env util.load_python_file(self.dir, "env.py") File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file module = load_module_py(module_id, path) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/util/compat.py", line 173, in load_module_py spec.loader.exec_module(module) File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "migrations/env.py", line 96, in run_migrations_online() File "migrations/env.py", line 90, in run_migrations_online context.run_migrations() File "", line 8, in run_migrations File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/runtime/environment.py", line 846, in run_migrations self.get_context().run_migrations(kw) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/runtime/migration.py", line 518, in run_migrations step.migrationfn(**kw) File "/home/ubuntu/flask-microblog/migrations/versions/149feea4a7a8.py", line 28, in upgrade sa.PrimaryKeyConstraint('id') File "", line 8, in create_table File "", line 3, in create_table File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/operations/ops.py", line 1250, in create_table return operations.invoke(op) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/operations/base.py", line 345, in invoke return fn(self, operation) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/operations/toimpl.py", line 101, in create_table operations.impl.create_table(table) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/ddl/impl.py", line 252, in create_table self._exec(schema.CreateTable(table)) File "/home/ubuntu/venv/lib/python3.6/site-packages/alembic/ddl/impl.py", line 134, in _exec return conn.execute(construct, *multiparams, params) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 988, in execute return meth(self, multiparams, params) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection return connection._execute_ddl(self, multiparams, params) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1050, in _execute_ddl compiled, File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context e, statement, parameters, cursor, context File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 152, in reraise raise value.with_traceback(tb) File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context cursor, statement, parameters, context File "/home/ubuntu/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table user already exists [SQL: CREATE TABLE user ( id INTEGER NOT NULL, username VARCHAR(64), email VARCHAR(120), password_hash VARCHAR(128), about_me VARCHAR(140), last_seen DATETIME, PRIMARY KEY (id) )

] (Background on this error at: http://sqlalche.me/e/e3q8)