Skip to content

Correction to the select function argument in ch04#5

Open
shazic wants to merge 1 commit into
oreillymedia:masterfrom
shazic:master
Open

Correction to the select function argument in ch04#5
shazic wants to merge 1 commit into
oreillymedia:masterfrom
shazic:master

Conversation

@shazic

@shazic shazic commented Jul 1, 2023

Copy link
Copy Markdown
  • As per the SQLAlchemy Core documentation, 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 *

 - 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=<orders>), Column('username',
   String(length=15), table=<users>, nullable=False), Column('phone',
   String(length=20), table=<users>, nullable=False)].
   Did you mean to say select(Column('order_id', Integer(),
   table=<orders>), Column('username', String(length=15), table=<users>,
   nullable=False), Column('phone', String(length=20), table=<users>,
   nullable=False))?

 - Instead of sending the list, pack the arguments using *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant