redirector: migrate sql interface to sqlalchemy

* Replace run_sql queries with SQLAchemy query.

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
- use `.exists()`
- Do we need this function? If not then please remove it.