From the course: Advanced SQL for Application Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Create an ORM model

Solution: Create an ORM model

From the course: Advanced SQL for Application Development

Start my 1-month free trial

Solution: Create an ORM model

- [Narrator] Now, the solution to the challenge of creating a supplier class is shown here. It's a very simple pattern. We are going to build a class and we're going to build it off the base class which we have defined using the declarative statement we had created earlier. Now, we always need to specify a table name, and the table name has two underscores as a prefix and as a suffix. So we specify __tablename__ as suppliers. The supplier_id is an integer, so we specify an Integer, and since it's the primary key we pass in the primary_key Boolean and specify True. The supplier_name and supplier_region are both strings so we specify Columns of type String. And then finally, the supplier_level is an integer so we specify a Column of type Integer.

Contents