Do not se exec_environment.

create a module (not a model) and in it put something like:

from gluon import *
def define_common_tables(db):
      request, response, session, cache, T = current.request, 
current.response, current.session, current.cache, current.T
      db.define_table('table1',....)
      db.define_table('table1',....)
      db.define_table('table1',....)
      db.define_table('table1',....)


then wherever you need you import the module and call the function 
define_common_table(db) to define your tables.


On Saturday, 7 April 2012 01:13:55 UTC-5, Ronghui Yu wrote:
>
> Hi, All,
>
> I would like to write some Python script for doing database house keeping 
> work, and I would like to reuse the table definitions defined in 
> models\db.py. But I am not able to import it since models is not a package, 
> and I was trying to use exec_environment() to do that, but it request a 
> complete setting of request, response, and session. I am just wondering if 
> there is a simple way to reuse the db definition, so that I could operate 
> on databsse in the script in the same way as that in controller.
>
> Thanks a lot
>
> -- 
> ===========================
> Regards
> Ronghui Yu
>  

Reply via email to