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 our user. And let's just go ahead and make a copy paste because there will
0:07 be some similarities here. So I'll just call this user and we'll make a few changes. So user like that, we're going to have an id.
0:14 In our database, as every entry has to, also have a created date. But from then on, it's going to be a little bit different.
0:22 So our users are going to have a name, which is a string, a phone, which is a string, an email, which is a string. We're also going to have orders,
0:32 which is going to be a list, and let's actually use the typing. And this is going to be a list of being come up here and import order
0:41 and say this is a list of order and so on. All right now that defines our basic user class, and we want to do something similar here.
0:50 We're going to have a user, but in order to specify what type it is, you can't import user here that will actually cause an issue.
0:57 So I'll just say this is a user like so, we'll get a warning by pycharm. But that's okay. It'll figure out what it is in the end.
1:04 All right, so we've got our user class created Name and email we've collected as part of our studio flow phone number comes directly from the trigger.
1:13 Remember that when they come in, they actually initiate this WhatsApp conversation with their phone, which provides us their phone number.
1:20 We store this. This will be auto incremented, and this is just going to be the relationships between the customers or the users and
1:26 their orders. Right? There are two main top level SQLAlchemy classes that we're going to work with.


Talk Python's Mastodon Michael Kennedy's Mastodon