I am trying to execute a raw query to a PostgreSQL database that works with SqlAlchemy in a Flask project.
I have a class Project and want to query against an array using the IN operator
This is the query that works:
db.session.execute( "SELECT * \
FROM project\
WHERE project.id IN (1,2,3)"
)
Instead of (1,2,3) I want to pass a variable but cannot figure out how to do that.
I want to do something like:
db.session.execute( "SELECT * \
FROM project\
WHERE project.id IN
(my_array)"
)
I have tried this but does not work:
db.session.execute( "SELECT * \
FROM project\
WHERE project.id IN
param",
{"param":(1,2,3)}
)
Please help!:)