Setting up the database

  • Create our models
  • Create our database


First, go to the website.
open the download page
After download set the path “sqlite” :- open system properties>environment variable >path>open new windows >edit>new(copy sqlite path )>ok.

Test sqlite:

open cmd administrator – give command sqlite3 (its show version sqlite)


SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power sql.


pip install flask-sqlalchemy

Create database in our project-
open notes —


Open your terminal

give command–python(open python terminal)
Command–from app import db
db.create_all()(this working means database create name “noter”)

Flask migrate

  • When u creating a model for database table ,you will sometimes need to adjustments to the model,such as adding new row.
  • Upon making these changes,you will need to migrate these changes in order to update the database table
  • Pip install flask-migrate

Flask migrate command

  • Set the Flask_APP environment variable> set FLASK_APP = “filename”
  • Setup the migrations directory—flask db init
  • Set up the migrations on file—- flask db
  • migrate -m “some message”
  • Update the database with the migration —-flask db upgrade

First create database-

class User(db.Model)-

Open terminal:– python shell

Command:->> from app import db
>> db.craete_all()

(your database created)


set FLASK_APP= “filename”

flask db init

Open chat