#100DaysOfCode in Python Transcripts
Chapter: Days 88-90: Home Inventory App
Lecture: Home Inventory app run through

Login or purchase this course to watch this video and the rest of the course contents.
0:00 And here's the final code here on the right. We'll go through it very quickly, not in too much detail. But essentially, start down the bottom.
0:10 We can see we launched our first launch first, okay? And the reason we do this is this will generate the database for us on first launch.
0:21 So as soon as this is run, it tries to connect to the SQLite3 database, and then it just fails while the except scenerio here
0:29 is to just exit out of the app with some error code X that can be expanded on later if you feel like it. And this just ensures the we actually have
0:38 a database file to talk to, inventory.db on the very first time that you launch this app. Okay? And then we pop back down and we're launching
0:48 Main Menu here. We're running the main menu. And down here we've seen that before, these are all your different options, okay?
0:57 Now if you want to add room, we then go down here to Add Room. And again, we've seen the Scrub, we're seen
1:03 the Create the Table based on the user's input. Done. A room with the name has been added to the database,
1:10 then we can run the inventory check, add inventory with the check input. Okay, so we'll just do a quick Check Input here.
1:18 We've seen that again, it just checks to see if the name exists. If it doesn't exist, it just returns. Else it will scrub the selection.
1:30 It will use that scrub function again here. It'll scrub it and it'll return it to Add Inventory. We'll pop down to Add Inventory here.
1:40 Now the reason we want it scrubbed is because that selection that the person made is going to be used in our Execute command here into the database.
1:50 So as they enter the item, it will execute insert into the room that they use as specified. Okay? And then it will enter in the item values.
2:03 And it will then give them the option to keep entering items or to quit, which will take them back to the main menu. Okay? Back to the main menu.
2:16 View Inventory, similar sort of thing as Add Inventory. Okay, the user selects a room. And then it will actually go through and add up
2:27 everything in that room. So you can see we've got data[0] and data[1]. It will actually go and print out the total of data[1],
2:33 one being the value from our SQLite database. So we're selecting from, the room that the user specified, we're selecting everything from there,
2:46 and then we're going to just add up the values, or those real values, and display it on screen. The other function that we haven't touched on
2:55 yet is Calc Total, which is pretty much going through every single room, okay? It'll go through every room in the database,
3:04 add up all the values, add it to the total, and then you'll get a total down the bottom. Okay? So that's pretty simple, right?
3:11 We've got everything covered there. All right, let's actually run it and see how it works. So this will create a new database file
3:21 called inventory.db because I don't have one. And then we'll add the room. What name would you like to give the room? Let's call it Kitchen.
3:32 Okay a room with the name Kitchen has been added to the db. Let's add some inventory. Okay, which room? Okay let's choose Kitchen.
3:41 And what item do we want to add in? Let's put in Fridge. Monetary value of the fridge is let's say 900 bucks. Okay, let's add something else.
3:52 Let's add the oven. Let's say it's $1200.00. Okay we'll hit q. And now it can view the inventory list with three.
4:03 Which room, kitchen, and it came up saying we've got a fridge of 900 bucks, we have an oven of $1200.00, total value of $2100.00.
4:14 Okay, so we know that's the math there works. All right, let's add another room quickly. Let's call it the Study. All right?
4:24 Let's add some inventory to the study. Okay let's call it the Computer. And let's say it's a value of $2500.00.
4:34 Okay we don't want to add anything else. And now if we do View Inventory List, we can see both rooms. We choose the Study, we can see the study
4:45 just has a computer in it for $2500, total value of $2500. Now if we want to see the total value of the entire house, we can click on number four.
4:56 Total value of all rooms is $4600.00. And that's it. Okay, that's pretty much


Talk Python's Mastodon Michael Kennedy's Mastodon