On Thursday, June 16, 2016 at 12:13:45 PM UTC-4, Pierre wrote: > > well, why would someone want to instantiate a web2py db connection outside > of web2py (in a module) ? >
There's no reason use of the DAL for database access should be limited to HTTP requests. Not all database work involves web applications, and even within the context of web applications, not all database access happens within HTTP requests (e.g., a periodic task to archive old records). I thought *current.db* is the standard way to access db from a module ? > That is one way to access the db object within a module when the code will be run within a web2py execution environment (code is run in a web2py execution environment during HTTP requests, during scheduler tasks, and when running the web2py shell). Another option is just to pass the db object to the relevant class or function in the module. Anyway, use of current.db has nothing to do with whether or not you need to call db.commit(). > So if the book doesn't refers to *current.db* speaking of > insert/update/delete ops in modules, I don't know what it refers to ? > It does, but the code in a given module may or may not be running in a web2py execution environment, so it may or may not be relevant to use current there. Furthermore, even if in a web2py execution environment, the code may or may not be running in the context of an HTTP request, so you may or may not have to call db.commit(). Use of current.db and calling db.commit() are to independent concerns. Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.