Can you show the part of *your* code that is triggering the error, and
explain what you are trying to do? Plain python properties aren't
normally very useful when accessed via a class. "Genome.attributes"
returns a property object, not the return value from the function, and
I don't understand what you are trying to do with it.

Thanks,

Simon

On Mon, Jan 24, 2022 at 2:03 AM Simon <htlbyd...@gmail.com> wrote:
>
> Hi there,
>
> I got a problem about 'sqlalchemy.exc.ArgumentError: SQL expression object 
> expected, got object of type <class 'property'> instead'
>
> My SQLAlchemy version is 1.3.22. I have a database like
>
> Class Genome:
>     id = Column(Integer, primary_key=True)
>     created_date = Column(Datetime, nullable=False)
>
> @property
> def attributes(self):
>      return "something"
>
>
> If using the query, it reports an error through the elements.py in the 
> sqlAlchemy
>
> def _literal_as(element, text_fallback):
> if isinstance(element, Visitable):
> return element
> elif hasattr(element, "__clause_element__"):
> return element.__clause_element__()
> elif isinstance(element, util.string_types):
> return text_fallback(element)
> elif isinstance(element, (util.NoneType, bool)):
> return _const_expr(element)
> else:
> raise exc.ArgumentError(
> "SQL expression object expected, got object of type %r "
> "instead" % type(element)
> )
>
> This exception is not raised if I directly query genome's column name such as 
> created_date or id.
>
> I am wondering 1) could the column name and property be used interchangeably 
> in some way? Or say how could to query a table's property in the way of 
> querying a table's column? 2) what are some significant differences between 
> table's column name and property?
>
> Thanks.
>
>
>
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/7f03c9bb-9324-4e3e-8aea-cd0d46f9021bn%40googlegroups.com.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexfKm%2Bx8AMg8de%2BXx5CQ6AM62%2BWfth3v%2BgGB8LzE9SbK%3Dw%40mail.gmail.com.

Reply via email to