Remove unused imports.
Use more specific SQLAlchemy exceptions.