You should use the built-in connection pooling mechanism for this purpose.
See
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Connection-pooling.
Anthony
On Tuesday, April 21, 2015 at 11:05:32 AM UTC-4, Michel Krav wrote:
>
> Hi,
> my goal is to save time at each request processing.
>
> my context is a connection to an Oracle database with unfortunately poor
> network response, so
> in model.py , defining :
> dbo = DAL(uri , auto_import = False, migrate = False , lazy_tables =
> False)
> on every request it cost time to connect.
>
> So, I decided to save the DAL object in a global variable.
> I prefered doing
> current.dbo = dbo
> than
> session.dbo = dbo
> in the model file, as it's not user dependent.
>
> and finally store it in the application cache :
> current.dbo = cache.ram('dbo', lambda: dbo , time_expire=60*60)
>
> then I only define table in other model/file dedicated to controller in a
> conditional model way.
>
> after test and debug it seems to work well (fell like saving time
> connection) but is it web2py proofed ?
>
>
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.