From e6d720ddb7f4619a5e3efc18e99b43d63e72a9b1 Mon Sep 17 00:00:00 2001 From: Shashank Chattopadhyaya Date: Sat, 1 Jul 2023 18:58:05 +0530 Subject: [PATCH] Correction to the select function argument in ch04 - As per the SQLAlchemy Core, To SELECT from individual columns using a Core approach, Column objects are accessed from the Table.c accessor and can be sent directly. - A list of columns is not accepted as an argument and throws the ArgumentError exception: E sqlalchemy.exc.ArgumentError: Column expression, FROM clause, or other columns clause element expected, got [Column('order_id', Integer(), table=), Column('username', String(length=15), table=, nullable=False), Column('phone', String(length=20), table=, nullable=False)]. Did you mean to say select(Column('order_id', Integer(), table=), Column('username', String(length=15), table=, nullable=False), Column('phone', String(length=20), table=, nullable=False))? - Instead of sending the list, pack the arguments using * --- ch04/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch04/app.py b/ch04/app.py index fe120fd..35b4471 100644 --- a/ch04/app.py +++ b/ch04/app.py @@ -10,7 +10,7 @@ def get_orders_by_customer(cust_name, shipped=None, details=False): dal.line_items.c.quantity, dal.line_items.c.extended_cost]) joins = joins.join(dal.line_items).join(dal.cookies) - cust_orders = select(columns) + cust_orders = select(*columns) cust_orders = cust_orders.select_from(joins).where( dal.users.c.username == cust_name) if shipped is not None: