document that SQLite cannot maintain temporary tables across more than one connection and that a special pool class must be used to maintain temporary tables across checkouts

Issue #2203 resolved
Former user created an issue

SQLAlchemy changed the way temporary tables are handled due to the pool class change in 0.7, which broke my app. I don't think temporary tables were intended to be quite so temporary. :-) Attaching an example.

Comments (12)

  1. Mike Bayer repo owner

    there's no bug here, simply use SingletonThreadPool or StaticPool if you need the same connection to remain persistent for all usages.

  2. Mike Bayer repo owner

    Also temporary tables aren't generally used across transactions in any case so the use case here is questionable.

  3. Former user Account Deleted
    • removed status
    • changed status to open

    I'm familiar with the workaround, and have already patched my app, but with all due respect I think you have closed this prematurely. Temporary tables are persistent per session (not per transaction) in sqlite, postgres and possibly other databases, and not to mention previous versions of SQLAlchemy. Given SQLAlchemy has deviated from the way (py)sqlite connections temp tables, I think at the very least this needs to be documented in the 0.7 release notes and SQLAlchemy's sqlite documentation so other people don't have to dig around to find out why their tables are disappearing.

    (do I need to reopen for you to get replies? if not, sorry)

  4. Former user Account Deleted

    Sorry, that should have read "the way (py)sqlite connections handle temp tables"

  5. Mike Bayer repo owner

    There is really nothing at all SQLAlchemy can do about this severe limitation of pysqlite. If Pysqlite blows away temp tables when a connection completes, that's a failure on Pysqlite's part IMHO - the NullPool approach is far more efficient and scalable for general use.

    Have you considered opening a bug with the Pysqlite/sqlite3 trackers ?

  6. Former user Account Deleted

    Thanks for updating the docs. I don't think this so much a bug in sqlite as intended behaviour - temp tables are specific to a connection and are lost when the connection is closed. I can see how NullPool could be a more useful default in the common case, and the number of affected people may be low as you say. I'm mildly curious about the performance implications of an implicit close on commit, as it means sqlite is throwing away its page cache and pysqlite loses its statement cache, but the effect is probably not that great. My primary concern was that the behaviour was not documented, and that's no longer the case. Thanks again!

  7. Mike Bayer repo owner

    I was having problems with locks and such and in my performance testing found that NullPool made on of my apps faster due to increased concurrency.

  8. Log in to comment