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