def session_for(dburi, **kwargs):
    engine = get_engine(dburi, **kwargs)
    if _SESSIONS not in dburi:
        _SESSIONS[dburi] = scoped_session(sessionmaker(bind=engine))
        ModelBase.query = _SESSIONS[dburi].query_property()

        # When a entity is instantiated, automatically add it to the Session
        @event.listens_for(mapper, 'init')
        def auto_add(target, args, kwargs):
            if isinstance(target, ModelBase):
                _SESSIONS[dburi].add(target)

    if not _SETUP['results']:
        ModelBase.metadata.create_all(engine)
        _SETUP['results'] = True

    return _SESSIONS[dburi]
dataset/ETHPy150Open ryanpetrello/cleaver/cleaver/backend/db/session.py/session_for/swapped operands of `not in`