Home » Flask SQLAlchemy

Flask SQLAlchemy

by Online Tutorials Library

Flask SQLAlchemy

Flask SQLAlchemy is an ORM tool which establishes the relationship between the objects and the tables of the relational databases.

The mapping between the both is important because the python is capable of storing the data in the form of objects whereas the database stores the data in the form of relational tables, i.e. the collection of rows and columns.

The object-relational mapping is the technique of storing python objects into the database tables without writing the raw SQL queries.

In this section of the tutorial, we will create a small web application using flask-sqlalchemy ORM techniques.

Install flask-sqlalchemy:

To create a web application using the flask ORM techniques, we must need to install flask-sqlalchemy using pip installer.

To confirm the installation, try to import the module on the python shell; if it is successfully imported, the installation is successful.

Creating a small web application using flask-sqlalchemy

In this section of the tutorial, we will create a CRUD Application in python using ORM SQLAlchemy.

Example

add.html

list_employees.html

app.py

Output: Flask SQLAlchemy

Click on the link Add new Employee to add a new employee to the database.

Flask SQLAlchemy

Click on Submit, and we will see the newly added employee in the list on the home page.

Flask SQLAlchemy


Next TopicFlask-WTF

You may also like