Separated db retrieval method from query handler in flaskapp/views.py