PS: I've tried using the auto_import=True option in DAL, but if I try to access any table, eg. db(db['table'].select(), I get KeyErrors
On 8 Feb, 09:28, giovanni allegri <gioha...@gmail.com> wrote: > Hi, > I'm moving my first steps ith web2py. > I'm considering it to setup a REST service where a user can upload > (zipped) sqlite DBs and view/edit their content through a web > interface. The db structure is fixed (it's the storage of a desktop > application), so I can define a model for it, but I wonder if it's > possible to use DAL dynamically. This is the workflow: > > 1 - the user uploads the file > 2 - the user accesses a certain page where the uploaded DBs are listed > (I keep the list in a simple model) > 3 - the user click on a DB and a page is opened with various options > to edit its contents. At this point web2py should expose a model bound > to the specific DB. > > I'm going to try the following way: > > 1 - define a method inside a model (e.g. inside /models/dynmodel.py) > which takes the DB path as an argument and the instanciate a DAL > object for it. > 2 - do a DAL.define_table.... and here come my doubts. What happens > when I do e define_table on a DB when the table already exists? > > I would like to know if someone has already solved a similar need, and > if there are "best practices" do do that in web2py. > thanks, > giovanni