ORM Sessions ride on top of connections, but since the Session under it's default pattern of being bound to an Engine does the "connect" internally, it's probably inconvenient to adapt the optimistic disconnect approach to it. You would probably want to bind the Session to the Connection explicitly. however, I would advise using pool_pre_ping instead which is much easier to use and has basically no downsides. this feature didn't exist when the docs for "optimistic disconnect" were written.
On Mon, Jun 7, 2021, at 5:52 PM, 'Matt Zagrabelny' via sqlalchemy wrote: > Greetings SQLAlchemy folks, > > I am following the guide at [0] for recovering from a database error in my > SQLAlchemy code. > > I normally use sessions for my SA work and am wondering if sessions will work > with the aforementioned SA example. My initial attempt to combine the example > at [0] with sessions did not seem to work as expected. What do folks think? > Should it work? > > Here is a code snippet of how I am creating sessions: > > connection_string = self.get_connection_string() > engine = create_engine(connection_string) > Session = sessionmaker(bind = engine) > > If folks believe it should work, then I'll formulate a minimal working > example and post my error. > > Thank you! > > -m > > [0] > https://docs.sqlalchemy.org/en/14/core/pooling.html#disconnect-handling-optimistic > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3Ud5spwMWPQTJws4zJixu7FuS5bLTu3OCmpxFLUpYn62A%40mail.gmail.com > > <https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3Ud5spwMWPQTJws4zJixu7FuS5bLTu3OCmpxFLUpYn62A%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/02c9b7e6-2046-4a02-9483-2e2752083137%40www.fastmail.com.