Flask is a Python framework which can be used to build the web application from scratch. Flask is micro frame work which capable to build websites like Instagram, twitter and anything at programmers will.
SqlAlchemy is a package in Python Flask which simplifies data base connections. The following simple Application will explain ….. how.
This project was built on windows OS and Pycharm IDE
The connection string
from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['DATABASE_FILE'] = 'app2.db' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + app.config['DATABASE_FILE'] app.config['SECRET_KEY'] = '123456790' db = SQLAlchemy(app)
So the db is like the cursor to the database.
Making of Database enabled Class
The User class exclusively has some database capabilities, such as querying tables. It is a fine example of how inheritance helping to build better applications.
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) email = db.Column(db.String(120), unique=True)