Reputation: 85
Hello I want to get only one query column using only Table.select()
, but I am having a problem
guild_id= 807887608943738881
guild = meta_data.tables['guild_'+str(guild_id)]
a= engine.execute(guild.select([guild.c.age]).where(guild.c.user_id== user_id)).fetchall()
print(a)
This code returns this
sqlalchemy.exc.ArgumentError: SQL expression for WHERE/HAVING role expected, got [Column('age', INTEGER(display_width=11), table=<guild_807887608943738881>)].
What's wrong with the age
column?
Upvotes: 4
Views: 2903
Reputation: 12018
It appears you are applying an illegal comparison in your where clause
, as per this note in the documentation 3rd party integration issue. My first suggestion would be to verify the type in the columns. But since they match (as per your comment), my next thought is to rearrange your query syntax – perhaps your query is attempting to apply a filter on an already instantiated query (which does not allow filtering on additional fields):
# Build your query according to v2.0 selector
q = guild.select(guild.c.age).where(guild.c.user_id== user_id)
# Get your results
res = engine.execute(q).fetchall()
Upvotes: 1