use db.query (redmine #1669)
check exit code of model execution (GH #112)

This only works for local/remote jobs, not for qsub.