I am using SQLAlchemy and would like to log executed SQL code (i.e. the code with all bind parameters already quoted and replaced). In case of psycopg2 it was possible using the query
attribute of the Cursor
object (see psycopg documentation). In case of MySQLdb it is possible using the _last_executed
attribute of the Cursor
object.
My question is: How can I retrieve the just executed query string using SQLAlchemy interfaces? Does it provide such functionality or should I write my own helper function?
Thanks in advance for any help.