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

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


You have to give %% to use it as % because % in python is use as string formatting so when you write single % its assume that you are going to replace some value with this.

So when you want to place single % in string with query allways place double %.


SQLAlchemy has a text() function for wrapping text which appears to correctly escape the SQL for you.

I.e.

res = executeSql(sqlalchemy.text(sql))

should work for you and save you from having to do the manual escaping.


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

engine.execute(sqlalchemy.text(sql_query))