SQLAlchemy ORM – Building Relationship This session describes creation of another table which is related to already existing one in our database. The customers table contains master data of customers. We now need to create invoices table which may have any number of invoices belonging to a customer. This is a case of one to […]
Category Archives: sqlalchemy
Working with Related Objects In this chapter, we will focus on the related objects in SQLAlchemy ORM. Now when we create a Customer object, a blank invoice collection will be present in the form of Python List. c1 = Customer(name = “Gopal Krishna”, address = “Bank Street Hydarebad”, email = “gk@gmail.com”) The invoices attribute of […]
SQLAlchemy ORM – Working with Joins Now that we have two tables, we will see how to create queries on both tables at the same time. To construct a simple implicit join between Customer and Invoice, we can use Query.filter() to equate their related columns together. Below, we load the Customer and Invoice entities at […]