Flask interaction with database