(venv) [florens@appelflap ark-vote]$ flask db init
[2018-05-05 20:11:36,899] INFO in __init__: Ark Poll startup
Creating directory /home/florens/PycharmProjects/ark-vote/migrations ... done
Creating directory /home/florens/PycharmProjects/ark-vote/migrations/versions ... done
Generating /home/florens/PycharmProjects/ark-vote/migrations/env.py ... done
Generating /home/florens/PycharmProjects/ark-vote/migrations/alembic.ini ... done
Generating /home/florens/PycharmProjects/ark-vote/migrations/script.py.mako ... done
Generating /home/florens/PycharmProjects/ark-vote/migrations/README ... done
Please edit configuration/connection/logging settings in '/home/florens/PycharmProjects/ark-vote/migrations/alembic.ini' before proceeding.
^CException ignored in: <module 'threading' from '/usr/lib/python3.6/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 1294, in _shutdown
t.join()
File "/usr/lib/python3.6/threading.py", line 1056, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.6/threading.py", line 1072, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt
As you can see I had to interrupt it using ctrl + c.
This isn't related to this package. Do you have any background threads in your project? Make sure they don't launch unless you start the application as a web server.
Found the package that caused it. I assume I have to use if __name__ == '__main__' to fix this?
That would be one way, but that is only going to work if you start your web server by running the main script directly (i.e. not via flask run or gunicorn, etc.).
You can also use the @app.before_first_request decorator to have a function execute right before the first request is received by the application.
Alright, thanks. I deleted the previous migrations folder because it might have been broken and ran flask db init again. Now when I run flask db upgrade I get this: https://pastebin.com/C6fPs472
EDIT: forgot I still had the db in the folder.
This is because your database was already migrated, and now you deleted the migrations. If you are using a scratch database, then delete it and start over. If you have data that you need in that database, then I recommend you recover those migration scripts from source control.
am still stock there
this was all i got
lb@LB:~/myshop$ python3 run.py db upgrade
/usr/lib/python3/dist-packages/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.
warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.')
/home/lb/myshop/application/web_forms.py:2: FlaskWTFDeprecationWarning: "flask_wtf.html5" will be removed in 1.0. Import directly from "wtforms.fields.html5" and "wtforms.widgets.html5".
from flask_wtf.html5 import NumberInput
Traceback (most recent call last):
File "run.py", line 6, in
manager.run()
File "/home/lb/.local/lib/python3.7/site-packages/flask_script/__init__.py", line 417, in run
result = self.handle(argv[0], argv[1:])
File "/home/lb/.local/lib/python3.7/site-packages/flask_script/__init__.py", line 386, in handle
res = handle(args, *config)
File "/home/lb/.local/lib/python3.7/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(args, *kwargs)
File "/usr/lib/python3/dist-packages/flask_migrate/__init__.py", line 259, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/usr/lib/python3/dist-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/usr/lib/python3/dist-packages/alembic/script/base.py", line 427, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/lib/python3/dist-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/usr/lib/python3/dist-packages/alembic/util/compat.py", line 82, in load_module_py
spec.loader.exec_module(module)
File "
File "
File "migrations/env.py", line 22, in
current_app.config.get('SQLALCHEMY_DATABASE_URI'))
File "/usr/lib/python3/dist-packages/alembic/config.py", line 218, in set_main_option
self.set_section_option(self.config_ini_section, name, value)
File "/usr/lib/python3/dist-packages/alembic/config.py", line 245, in set_section_option
self.file_config.set(section, name, value)
File "/usr/lib/python3.7/configparser.py", line 1197, in set
self._validate_value_types(option=option, value=value)
File "/usr/lib/python3.7/configparser.py", line 1182, in _validate_value_types
raise TypeError("option values must be strings")
TypeError:
when i run the ugrade or migrate command i get error.
@georgegoldman this problem has been mentioned before: https://github.com/miguelgrinberg/Flask-Migrate/issues/63
Most helpful comment
That would be one way, but that is only going to work if you start your web server by running the main script directly (i.e. not via
flask runorgunicorn, etc.).You can also use the
@app.before_first_requestdecorator to have a function execute right before the first request is received by the application.