#100DaysOfWeb in Python Transcripts
Chapter: Days 33-36: Database access with SQLAlchemy
Lecture: Your turn: Days 3 and 4

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's time again for you to write some code
0:02 so here we are in the SQLAlchemy section of our GitHub repo
0:05 and we have our demo code that we created during the course
0:09 and we have your turn
0:11 and this is a set of steps for you to follow, of course
0:14 so if we come over here, notice there's no starter code.
0:17 You're going to just start from scratch here
0:19 and the first two days, just watch the videos.
0:22 If you got to this video by watching them in order
0:25 first two days are done. You've finished that part.
0:27 Congratulations, and then day three and four of this section
0:32 is where you write some code. One thing we could have done
0:34 is said we're going to model a blog
0:37 and you're going to have posts, and categories, and tags
0:39 and et cetera, and that may or may not be interesting.
0:42 There's so many things like that, right?
0:44 So, we wanted to give you a little more flexibility
0:47 and what I've done here is
0:49 I've picked 18 database project ideas
0:53 so come over here to this website, scroll down
0:56 you can see it here
0:57 do you want to create a inventory management database
1:00 student school record system, online retail
1:03 college database, hospital, library, whatever
1:06 and each one, it talks a little bit
1:08 about the details of how you're going to do that
1:10 and what you need to keep
1:12 so your goal will be to go through here
1:15 and pick one of these 18
1:16 or if you just get inspired
1:18 and there's something derivative of that
1:20 then pick that other one.
1:22 What you're going to do on day three
1:24 is to pick one of those projects
1:26 come up with the SQLAlchemy classes to model it
1:30 set up the database connection
1:32 and put the unit of work pieces in place
1:35 like the session factory and so on
1:38 so if you need help remembering how to do that
1:41 you can come over here and pull up the demo code
1:44 so for example, under data we have our session factory.
1:47 This shows you how to connect to the database
1:49 using SQLite, for example, and go over to the models
1:53 open that up, see how you create a class, right
1:56 things like this.
1:57 Your job is to put the basic data model in place
2:00 in Python and SQLAlchemy after you pick one of these
2:03 following the ideas that go there.
2:05 You don't have to do anything with it.
2:06 Just get it all in place.
2:08 That's what you do on day four
2:10 so speaking of day four, now that you have this connection
2:14 these database models and so on
2:16 your job is going to be either to ask the user for some data
2:19 so they can type it in and you can query it
2:22 or go out, search the Internet
2:23 for data that seems like worthwhile that you could import
2:27 and then write a little script to import it.
2:29 Either way, your job is to insert some data
2:31 so you have data in your database
2:33 and then ask a few interesting questions.
2:36 These are not wide open
2:37 like you say there are three things
2:38 like in our scooter example
2:40 you could ask where are the available scooters?
2:42 Which ones are rented?
2:44 Which ones are available for renting?
2:46 And what's my history? Like, a couple of questions like that.
2:48 So, come up with a couple of questions
2:50 you might ask about the data
2:51 and then write the queries to answer them, and that's it.
2:55 Day three, you create the database model.
2:56 Day four, you put some data in there and you use it.
2:59 After that, hopefully
3:00 you'll find SQLAlchemy really approachable
3:02 and it takes a little bit of practice.
3:04 There's a lot of moving parts.
3:06 Once you get those parts, it's kind of like driving.
3:07 Much of it fades to the background
3:09 and it's a really sweet system
3:10 for building data-driven
3:12 relational database-based applications in Python.