Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"autocommit=True is no longer supported" #114

Open
7dir opened this issue Aug 25, 2024 · 1 comment
Open

"autocommit=True is no longer supported" #114

7dir opened this issue Aug 25, 2024 · 1 comment

Comments

@7dir
Copy link

7dir commented Aug 25, 2024

session = scoped_session(sessionmaker(bind=engine, autocommit=True))

@challapradyumna
Copy link

Yet to fully test but the below code seems to work at this point of time :
Reference: Sqlachemy 2.0 Migration Guide

@contextmanager
def session_scope():
    """Provide a transactional scope around a series of operations."""
    session = SessionLocal()
    try:
        yield session
        session.commit()
    except:
        session.rollback()
        raise
    finally:
        session.close()


with session_scope() as session:
    BaseModel.set_session(session)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants