def get_repository_by_id( app, id ):
    """Get a repository from the database via id."""
    sa_session = app.model.context.current
    if app.name == 'galaxy':
        return sa_session.query( app.model.ToolShedRepository ).get( id )
    else:
        return sa_session.query( app.model.Repository ).get( id )