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>
I think we should change the logic a bit here.

1. add new kb with given name
2. if there is consistency exception (name exists), rollback and try again with `name + str(i+1)`.
3. add new optional argument e.g. `tries=10` so `i` is always less than `tries`.