пятница, 1 сентября 2017 г., 15:26:11 UTC+3 пользователь Антонио Антуан написал: > > Hi guys. > I have several questions and, possibly, misunderstandings about sqlalchemy > connection pooling behavior > > 1. I try to figure out if this is normal: > https://gist.github.com/aCLr/be78f3495892978ee868c9b5adcef0e6 > > As you can see, I checked that `bind` is the same on `get_bind()` > invokation and on attribute call. > I see, that each connection into session binds only for session, not for > bind... > Is it correct? I expected that each connection is bound for `bind` > (`engine`). > > > > > 2. Here is the problem, on which I started my research: > https://gist.github.com/aCLr/b642c822b0bd3c9ec1fe775452479acd > I don't use commit here, only flush. But I expected that results on each > execution will be the same, because I used same bind on query compilation > and on `Session.query...` execution. > > Yes, I've read about `reset_on_return` parameter of Pool. And when I > specify that parameter with `None` value, failed only first asserion > ('failed on compiled query execution') because, as I think, another > connection is used. > My question is the same: isn't it wrong? And if it is, how can I avoid > AsserionError on compiled query execution? Should I use private ` > _connection_for_bind` method of Session class or there are any other > options? >
My fault, compiled query was wrong. Fixed it: https://gist.github.com/aCLr/22d6ed61c1dd49530d30c218a65a2680 Now the second raw sql fails without `pool_reset_on_return=None` > > -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.