oh... variable s like that :) left the window open for too long and
didn't see the reply

On Mar 22, 3:54 pm, mart <msenecal...@gmail.com> wrote:
> I use this as a generic function table names are variables (I use a
> shortcut -so other modules can just do select(x,y) or update(x,y,z). I
> guess the same can be extended a little bit to make use/enable more
> variables...
>
>    def updateStorage(self,tbl,name,value,cmdName=None):
>         db = self.db
>         id = None
>         rowID = None
>         for mTbl in db.tables:
>             if tbl in mTbl:
>                 if mTbl.startswith(tbl):
>                     rows = db(db[mTbl].name==name).select()
>                     for row in rows:
>                         if row.name == name and row.value > 0:
>                             id = row.id
>         if id != None:
>             rowID =
> db(db[tbl].name==name).update(name=name,value=value)
>         else:
>             rowID = db[tbl].insert(name=name,value=value)
>         if cmdName is not None:
>
> db(db[tbl].id==rowID).update(cmdName=cmdName)
>         db.commit()
>         return rowID
>
> On Mar 22, 3:28 pm, LightOfMooN <vladsale...@yandex.ru> wrote:
>
>
>
>
>
>
>
> > I have table with too much cols.
> > So, is there a way to pass variable names and values in the insert()
> > or update() methods like this?
>
> >     options_house =
> > db(db.company_houses_options.company_id==company.id).select().first()
> >     if request.vars.edit_options_house:
> >         houses_options={}
> >         for column_name in houses_columns:
> >             if request.vars.get(column_name, None):
> >                 houses_options[column_name]=True
> >             else:
> >                 houses_options[column_name]=False
> >         options_house.update_record(houses_options)
>
> > where houses_columns is a list of columns names like
> > ['street','house','block','buildyear',...]

Reply via email to