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

Talk Python's Mastodon Michael Kennedy's Mastodon