From the course: Introduction to Python: Learn How to Program Today with Python by Pearson
Unlock this course with a free trial
Join today to access over 25,400 courses taught by industry experts.
Hook up a database - Python Tutorial
From the course: Introduction to Python: Learn How to Program Today with Python by Pearson
Hook up a database
Okay, so let's make some of that data be persistent across server refreshes and different users and things like that. So let's hook up a database. The databases are for storing data and it's retained if the server gets restarted. We could actually save these as variables hard-coded in the global scope of our app.py or just in our program, but if they were like that, then if their server restarted, they would get initialized back to zero. In a database, you can query for what data you want. For example, users who haven't logged in in over a year, and there are a bunch of different database options you can use. SQLite is just a basic text file, and it's good for really quick databases in development, but don't use it in production. It's just meant for development, testing things out. That's what we're going to use in this lesson, because you don't have to install anything extra, set it all up. It's just a text file, which is nice. There's also Postgres and MySQL. These are really common…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Learning objectives1m 20s
-
(Locked)
Look at the anatomy of a web app9m 20s
-
(Locked)
Start a web app with Flask12m 33s
-
(Locked)
Create a static page19m 55s
-
(Locked)
Get content from the back-end19m 27s
-
(Locked)
Make the page dynamic14m 32s
-
(Locked)
Hook up a database20m 25s
-
(Locked)
Get more context: Databases and deployment5m 58s
-
(Locked)
-