From the course: Advanced Python: Practical Database Examples
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Integrate project data from a Database into Flask - Python Tutorial
From the course: Advanced Python: Practical Database Examples
Integrate project data from a Database into Flask
- [Instructor] Let's create some database models so we can reference the data from our database and our flask application. We'll create these models using the Model object from our db variable. We'll set the table name to projects and create our columns. For column and integer, we reference the db object to get access to these types, but otherwise, it looks pretty similar to our SQLAlchemy code. In order to access the task data, we'll also need to create a Model class. But first, let's make sure the project data renders as expected. We'll add the functionality so our homepage displays all of our projects. To do this, we'll need to feed our projects into our index.html. We'll add another argument to our render_template call. project.query.all grabs all of the records in our projects table. Since we're using the Flask SQLAlchemy extension, and basing our models off of the db model, we're able to query all of our…
Contents
-
-
-
-
-
Set up Flask in a Python application2m 20s
-
(Locked)
Create a webpage with Flask2m 52s
-
(Locked)
Build a landing page3m 7s
-
(Locked)
Develop additional routes to enhance your application4m 56s
-
(Locked)
Build a project tasks page2m 16s
-
(Locked)
Create a Postgres database2m 1s
-
(Locked)
Instantiate a Postgres table using Python3m 43s
-
(Locked)
Connect a database to a Python Flask project1m 52s
-
(Locked)
Integrate project data from a Database into Flask2m 57s
-
(Locked)
Integrate task data from a database into a Flask app3m 9s
-
(Locked)
Develop add functionality to add a project5m 7s
-
(Locked)
Develop add functionality to add a task2m 10s
-
(Locked)
Challenge: Develop delete functionality1m
-
(Locked)
Solution: Develop delete functionality7m 13s
-
-