stmnt = (my_table.c.name == 'some name')
q = my_table.select().where(stmnt).limit(10)
result = connection.execute(q).fetchall()
Output: { "errorMessage": "SQL expression object expected, got object of type <class 'sqlalchemy.sql.elements.BinaryExpression'> instead", "errorType": "ArgumentError", "stackTrace": [ [ "/var/task/app.py", 59, "lambda_handler", "q = my_table.select().where(stmnt).limit(10)" ], [ "<string>", 2, "where", "" ], [ "/var/task/lib/sqlalchemy/sql/base.py", 47, "_generative", "fn(self, *args[1:], **kw)" ], [ "/var/task/lib/sqlalchemy/sql/selectable.py", 3477, "where", "self.append_whereclause(whereclause)" ], [ "/var/task/lib/sqlalchemy/sql/selectable.py", 3689, "append_whereclause", "self._whereclause = and_(True_._ifnone(self._whereclause), whereclause)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 2098, "and_", "return cls._construct(operators.and_, True_, False_, *clauses)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 2030, "_construct", "for clause in util.coerce_generator_arg(clauses)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 2030, "<listcomp>", "for clause in util.coerce_generator_arg(clauses)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 4569, "_expression_literal_as_text", "return _literal_as_text(element)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 4592, "_literal_as_text", "return _literal_as(element, _no_text_coercion)" ], [ "/var/task/lib/sqlalchemy/sql/elements.py", 4584, "_literal_as", "\"instead\" % type(element)" ] ]}Function error: Unhandled
# Get DB connection engine = setup_env_db_engine(debug=True) connection = engine.connect()
# Configure SQLalchemy meta = MetaData(bind=engine) meta.reflect()
my_table = meta.tables.get('my_table')
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAFHwexfyHn5OKiAm8k9QX3R3Gm4xAoZRy7%3Dg33L%3DdO%3DvSDumZg%40mail.gmail.com.
Can you show the real code that runs the query? I'm wondering whether
the thing that you are comparing against my_table.c.name is not
actually a simple string.
Simon
On Wed, Feb 12, 2020 at 11:01 PM Mark Wilkins <cont...@markwilkins.dev> wrote:
>
> Some additional code incase its relevent:
>
> # Get DB connection
> engine = setup_env_db_engine(debug=True)
> connection = engine.connect()
>
> # Configure SQLalchemy
> meta = MetaData(bind=engine)
> meta.reflect()
>
> my_table = meta.tables.get('my_table')
>
>
> --
> 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 sqlal...@googlegroups.com.
this looks like something up with the environment or the interpreter. The error message says it got an object whose type() returns "BinaryExpression". that is exactly the type it is looking for; this class should be a subclass of sqlalchemy.sql.visitors.Visitable. However for this error to occur, that is suddenly not the case, or the Visitable / BinaryExpression symbol has been modified at runtime, something like that. It's not clear if this could be some artifact of AWS Lambda, or the way the application is doing imports, or something like that.the approach here would be to make a test program that produces the error under AWS Lambda, then run it in a local Python environment and see if the results are the same or different.On Fri, Feb 14, 2020, at 5:16 AM, Simon King wrote:
Can you show the real code that runs the query? I'm wondering whetherthe thing that you are comparing against my_table.c.name is notactually a simple string.SimonOn Wed, Feb 12, 2020 at 11:01 PM Mark Wilkins <cont...@markwilkins.dev> wrote:>> Some additional code incase its relevent:>> # Get DB connection> engine = setup_env_db_engine(debug=True)> connection = engine.connect()>> # Configure SQLalchemy> meta = MetaData(bind=engine)> meta.reflect()>> my_table = meta.tables.get('my_table')>>> --> SQLAlchemy -> The Python SQL Toolkit and Object Relational Mapper>>> 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 sqlal...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/839938dd-ed33-4f55-a836-185ec0689f2f%40googlegroups.com.--SQLAlchemy -The Python SQL Toolkit and Object Relational MapperTo 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 sqlal...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/5ca02432-e957-412d-91a4-4f4c9dd67f0c%40googlegroups.com.