Building data-driven web apps with Flask and SQLAlchemy Transcripts
Chapter: Using SQLAchemy
Lecture: Setting package values
0:00 Okay off to a good start and we no longer
0:02 need this so this is good.
0:04 Now what we need to do, let's just say while true
0:09 we're going to insert a package.
0:12 We'll write a little function that will does that.
0:14 So down here, this can just enter package.
0:17 So how do we insert a package and maybe some releases
0:21 that are related to it?
0:23 Well, how would you create a package if you forgot about the
0:26 database and you only thought in classes and objects?
0:28 You would say this p = Package(), like so, and you would
0:31 import that from pypi_org.data.package.
0:35 You would set some properties like the id might be, and
0:38 we could ask the user input package id, name
0:44 and we could do a strip in the lower
0:47 just to make sure that is all consistent.
0:50 What else do we need to set?
0:51 Well, let's go actually look at our package real quick here.
0:54 And we can say, what do we need to set?
0:55 Well this, sometimes we don't have to set the primary key.
0:58 This one is not auto_incrementing so we do.
1:01 This one has a default value so that's solid.
1:04 These could all be set, the releases
1:06 we'll deal with in a second.
1:09 So let's go over here and just put a little
1:10 long comment string to show us what we got to do.
1:15 So it'll be
1:17 p.summary = input("Package summary: ").strip()
1:23 For description I think we'll just ignore that
1:25 all of those we can ignore.
1:27 Let's just put author name and license.