u/evereux

▲ 3 r/flask

flask db = Error: No such command 'db'

OS: Windows 11 python: 3.9.13

I have two machines (main, laptop) running Windows 11. The main machine I have recently re-formatted. On this machine I've cloned my github repo, set up the environment, installed the requirements (from requirements.txt file in repo) and set up the projects configuration files.

The application itself works fine with flask run. The database can be read from and written to.

On the main machine if I do flask db migrate -m "my new table" I get the error message flask db = Error: No such command 'db'. .

Running flask --help outputs the folllowing:


  A general utility script for Flask applications.

  Provides commands from Flask, extensions, and the application. Loads the
  application defined in the FLASK_APP environment variable, or from a
  wsgi.py file. Setting the FLASK_ENV environment variable to 'development'
  will enable debug mode.

    > set FLASK_APP=hello.py
    > set FLASK_ENV=development
    > flask run

Options:
  --version  Show the flask version
  --help     Show this message and exit.

Commands:
  add-admin          Add a admin user.
  add-groups         Add / update the default groups.
  routes             Show the routes for the app.
  run                Run a development server.
  shell              Run a shell in the app context.
  sync-odoo-lines    Update the odoo line items for all open projects.
  upcoming-projects  Email notification of status of upcoming projects.

We can see here that the command db isn't added.

The additional commands I have added are visible.


On my laptop (Windows 11, not reformatted) I can follow the same steps as above and the db command is available as expected.


A simplification of my structure is as follows:

	/application/
		/application_bp_1/
		/application_bp_2/
		/application_.../
		__init__.py
	.env
	...

__init__.py contains the application configuration

app = Flask(__name__)
db = SQLAlchemy(app)
migrate = Migrate(app, db)

So far I've

  • remade the env serveral times
  • uninstall python, cleared all cache files, reinstalled

I have tried looking for similar errors it seems to be all about initialising the db correctly which I'm sure I have done. Remember, this same project, cloned from the repo, same dependencies, same python version, works fine on the laptop.

Anybody have any idea what I've missed?

Any pointers on how to debug this?

reddit.com
u/evereux — 21 days ago