On Fri, Mar 5, 2021 at 8:34 AM Mike Bayer <mike...@zzzcomputing.com> wrote:

> yeah in fact that engine.begin() here is using a brand new SQLite
> connection each time as the default pool for SQlite files is NullPool, as
> it is a very fast connecting database and it is the safest option for
> concurrency.   So in your first example, you have a brand new file
> connection and all of your WAL setup code is running each tme.   In the
> second example, it runs only once.
>
> background on pooling:
>
>
> https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#threading-pooling-behavior
>
> if you use the SingletonThreadPool instead of the default NullPool, you
> will again get the same performance with engine.begin().  however, there is
> no need to change existing code that uses engine.connect() /
> connection.begin().
>

Got it, thanks.  I had read
https://docs.sqlalchemy.org/en/13/core/pooling.html#connection-pool-configuration
but managed to miss the fine print that SingletonThreadPool was used for
in-memory connections and NullPool was used for file connection.

-- 
Jonathan Brandmeyer

-- 
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/CA%2BXzfkoPwxu0EdHTHWK1Ya8xEMJ8NUdDnf%3DBNVxeBG8vLOsOJA%40mail.gmail.com.

Reply via email to