I have a query like this:
res = db.query("value").from_statement(
text("SELECT f.val AS value "
"FROM facts f, persons p"
"f.person_id=:region || p.id::text")
I am trying to build this SQL query:
SELECT f.val AS value
FROM facts f, persons p
WHERE f.person_id='us:' || p.id::text;
If I ran this query on psql it returns as expected. Now the problem I'm having here is using SqlAlchemy it returns 0 results, which makes me think perhaps the problem is in the region building using ::text. I couldn't find a way to print the actual query that sqlalchemy makes to the DB.
If I do print(str(res)) I get the what's inside text(). Any lights ?