Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Using SQLAlchemy
Lecture: Setting package values

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay off to a good start and we no longer need this so this is good. Now what we need to do, let's just say while true we're going to insert a package.
0:13 We'll write a little function that will does that. So down here, this can just enter package. So how do we insert a package and maybe some releases
0:22 that are related to it? Well, how would you create a package if you forgot about the database and you only thought in classes and objects?
0:29 You would say this p = Package(), like so, and you would import that from
0:36 You would set some properties like the id might be, and we could ask the user input package id, name and we could do a strip in the lower
0:48 just to make sure that is all consistent. What else do we need to set? Well, let's go actually look at our package real quick here.
0:55 And we can say, what do we need to set? Well this, sometimes we don't have to set the primary key. This one is not auto_incrementing so we do.
1:02 This one has a default value so that's solid. These could all be set, the releases we'll deal with in a second.
1:10 So let's go over here and just put a little long comment string to show us what we got to do. So it'll be
1:18 p.summary = input("Package summary: ").strip() For description I think we'll just ignore that all of those we can ignore.
1:28 Let's just put author name and license.

Talk Python's Mastodon Michael Kennedy's Mastodon