Refactoring to extract sqlalchemy related features for decoupling