Re: [sqlalchemy] About multithread session (scoped session)

2018-01-15 Thread gingerluo
Simon, Thanks for your kind answer. So when I have several threads trying to insert/update the same database (pgsql or sqlite) at the same time, how can I ensure consistency? By using scoped session? This will rely on the DB implementation behind, right? 在 2018年1月15日星期一 UTC+8下午5:21:42,Simon

[sqlalchemy] About multithread session (scoped session)

2018-01-15 Thread gingerluo
Hello, Sessions are not thread safe. But for the scoped sessions, each thread will have its own session, my question is, even the scoped session itself rely on the thread safety feature of the DB behind? for example, PGSQL server may handle multiple connections and resolving the update/insert

[sqlalchemy] [sqlalchemy/postgreSQL] way to handle server-end timeout

2018-01-11 Thread gingerluo
Hello, Is below the way to reconnect to postgresql server automatically? everytime I need to remake a session with "Session = sessionmaker(bind=engine) session = Session()" , is this right? the codes below can work, but if I don't remake the session, it will failed at server timeout.