Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask init-db no such command

Tags:

python

flask

From yesterday I read a lot of topics about the famous error:

"No such command init-db"

So, I followed the tutorial here: https://flask.palletsprojects.com/en/1.1.x/tutorial/database/

(I'm under Debian 9.6)

I do the following :

export FLASK_APP=webApp
export FLASK_ENV=development
flask init-db

I then tried:

python3 -m flask init-db

I also tried:

export FLASK_APP=webApp.py

But I still have the same error message.

Here is the tree of my project :

instance/
webApp/
├── auth.py
├── babel.cfg
├── dashboard.py
├── db.py
├── __init__.py
├── pdf.py
├── __pycache__
│   ├── auth.cpython-35.pyc
│   ├── db.cpython-35.pyc
│   ├── __init__.cpython-35.pyc
│   ├── pdf.cpython-35.pyc
│   └── ws.cpython-35.pyc
├── schema.sql
├── static

I didn't see what I've missed.

like image 694
Nathan Cheval Avatar asked Oct 15 '19 07:10

Nathan Cheval


People also ask

How do you initialize a db flask?

Initialize the Database File Run the init-db command: $ flask --app flaskr init-db Initialized the database. There will now be a flaskr. sqlite file in the instance folder in your project.

How do I move a table into a flask?

To first set up your migrations directory, we can run flask db init . This creates a new migration repository; in so doing, this command creates a couple of folders and files in our project root where our migrations will live. We only need to do this once.


1 Answers

I found the problem.
When I launched flask --help, I saw there was an import error of a module. I just installed that module via pip, and it was okay.

like image 126
Nathan Cheval Avatar answered Sep 17 '22 15:09

Nathan Cheval