SQLAlchemy and Postgresql: to_tsquery()
The .op() method allows you to generate SQL for arbitrary operators.
session.query(TableName).filter(
Table.c.column_name.op('@@')(to_tsquery(search_string))
).all()
For these type of arbitrary queries, you can embed the sql directly into your query:
session.query(TableName).\
filter("t.column_name @@ to_tsquery(:search_string)").\
params(search_string=search_string).all()
You should also be able to parameterize t.column_name
, but can't see the docs for that just now.