You are welcome!

;-)

Richard

On Tue, Jan 25, 2011 at 4:47 AM, Markus Schmitz <[email protected]>wrote:

> Hi Denes and also Massimo and Richard,
>
> 3 spot on answers in the range of 30 minutes. I am honestly impressed
> and again convinced to have chosen the right framework.
>
> Seeing the examples and playing with the 'for' and '*' operator,  the
> way to do it is clear now.
>
> Thanks all of you
>
> Markus
>
> On Jan 24, 4:51 pm, DenesL <[email protected]> wrote:
> > Hi Markus,
> >
> > I would do:
> >
> > FF=[Field('y%s'%k) for k in range(1,101)]
> > db.define_table('x',*FF)
> >
> > To access a field via an index just use:
> >
> > db.x['y%s'%index]
> >
> > Denes.
> >
> > On Jan 24, 8:38 am, Markus Schmitz <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi everybody,
> >
> > > I have the requirement to treat a range of table fields like an array.
> > > Example:
> >
> > > I have a table x with fields y1, y2, ...., y100. In normal SQL I could
> > > create the table by issuing an 'alter table x add field y...'
> > > statement in a loop and I would be able to access the fields by
> > > constructing the appropriate SQL command in a string.
> >
> > > So instead of using an index i and writing in theory: select y[i]
> > > from x
> > > I would write: ExecuteSQL("select y" + i + " from x)"
> >
> > > But in web2py:
> >
> > > Question 1: How can I create such a table definition in web2py without
> > > listing all fields manually?
> >
> > > Question 2: How can I use the DAL to access these fields using an
> > > index and avoid using the ExecuteSQL method?
> >
> > > Thanks in advance,
> >
> > > Markus
> >
> > > P.S.: I know I could simply create a small table, having two fields,
> > > basically "i" and "y", where "i" is part of the index. But in my case
> > > I end up with millions of records and quite an overhead for each data
> > > point. I tried it and performance was not satisfactory. But I am open
> > > for alternative suggestions.
>

Reply via email to