On Wednesday, June 8, 2016 at 10:15:37 AM UTC-4, Krishnakant wrote: > > So essentially opening a connection at the start of a class method/ > function, doing number of queries and then closing it just before return > would be the right strategy I think? >
No. The scope should last for one or more "units of work". If you are doing a website, the scope should be a web request. If you are running a commandline script, the scope would be the script itself. The connection may span multiple transactions, which are sqlalchemy's internal unit of work. > And is there some kind of cashing available for sql expression as well? > Baked Queries - http://docs.sqlalchemy.org/en/latest/orm/extensions/baked.html -- 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 post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.