sqlalchemy & #temp tables
Albert-Jan Roskam
sjeik_appie at hotmail.com
Mon Oct 7 11:30:57 EDT 2019
Hi,
I am using sqlalchemy (SA) to access a MS SQL Server database (python 3.5, Win 10). I would like to use a temporary table (preferably #local, but ##global would also be an option) to store results of a time-consuming query. In other queries I'd like to access the temporary table again in various places in my Flask app. How do I do that, given that SA closes the connection after each request?
I can do:
with engine.connect() as con:
con.execute('select * into #tmp from tbl')
con.execute('select * from #tmp')
... but that's limited to the scope of the context manager.
Oh, I don't have rights to create a 'real' table. :-(
Thanks!
Albert-Jan
More information about the Python-list
mailing list