knowledge: API migration to SQLAlchemy

* Replaces run_sql queries with SQLAchemy query.

* Refactors module in order to move logic from api to model.

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
@jmartinm this should be the row where the exception is catched and returned an empty array.
It's not here the NoResultFound error?
(I'm refering to your http://pastebin.com/7bx6Xraq )
Can you put on pastebin the error? :)