Python-powered chat apps with Twilio and SendGrid Transcripts
Chapter: Using our database with the SQLAlchemy ORM
Lecture: Defining the ORM user

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The other main SQLAlchemy class that we have to define is going to be
0:03 our user. And let's just go ahead and make a copy paste because there will
0:06 be some similarities here. So I'll just call this user and we'll make a few
0:10 changes. So user like that,
0:12 we're going to have an id.
0:13 In our database, as every entry has to, also have a created date.
0:17 But from then on, it's going to be a little bit different.
0:21 So our users are going to have a name,
0:23 which is a string, a phone,
0:25 which is a string, an email,
0:28 which is a string. We're also going to have orders,
0:31 which is going to be a list,
0:33 and let's actually use the typing.
0:35 And this is going to be a list of being come up here and import order
0:40 and say this is a list of order and so on.
0:43 All right now that defines our basic user class,
0:46 and we want to do something similar here.
0:49 We're going to have a user,
0:50 but in order to specify what type it is,
0:53 you can't import user here that will actually cause an issue.
0:56 So I'll just say this is a user like so,
0:58 we'll get a warning by pycharm.
1:01 But that's okay. It'll figure out what it is in the end.
1:03 All right, so we've got our user class created Name and email we've collected as
1:08 part of our studio flow phone number comes directly from the trigger.
1:12 Remember that when they come in,
1:14 they actually initiate this WhatsApp conversation with their phone,
1:16 which provides us their phone number.
1:19 We store this. This will be auto incremented,
1:21 and this is just going to be the relationships between the customers or the users and
1:25 their orders. Right? There are two main top level SQLAlchemy classes that we're going to work with.