knowledge: migrate sql interface to sqlalchemy

* Replaces run_sql queries with SQLAchemy query.

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>