Strange SQLAlchemy error message: TypeError: 'dict' object does not support indexing

前端 未结 8 1566
刺人心
刺人心 2020-12-02 11:53

I am using hand crafted SQL to fetch data from a PG database, using SqlAlchemy. I am trying a query which contains the SQL like operator \'%\' and that seems to throw SqlAlc

相关标签:
8条回答
  • 2020-12-02 12:24

    I cannot find the "executeSql" in sqlalchemy version 1.2 docs , but the below line worked for me

    engine.execute(sqlalchemy.text(sql_query))
    
    0 讨论(0)
  • 2020-12-02 12:25

    One more note- you must escape (or delete) % characters in comments as well. Unfortunately, sqlalchemy.text(query_string) does not escape the percent signs in the comments.

    0 讨论(0)
提交回复
热议问题