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

2018-01-15 Thread Simon King
That's a bit of a complicated topic. Database consistency is generally ensured by using transactions with an isolation level that is appropriate for your usage. Each thread/connection will be operating in a transaction. The transaction isolation level determines when one thread will see the

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