rows[1]._extra['a']
On Jun 19, 11:23 am, "Sebastian E. Ovide" <sebastianov...@gmail.com> wrote: > how can I access to the renamed column ? > > rows=db().select(db.mytable.date) > print len(rows) # > 100 > rows.colnames=["a"] > print rows[1] # EMPTY !!!! > print rows[1].a # ERROR !!!!!! > > if I do not change the column name I cna print rows[1] and rows[1].date > > any ideas ? > > On Fri, Jun 19, 2009 at 8:27 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > These are different problems. Even you could do "as", which you > > technically an but it is complicated, would not rename the web2py > > column. > > > You can rename the column without the "as". > > > rows=db(..).select(...) > > > rows.colnames is a list with the colnames. You can change any element > > in this list as you please. Look what is in there first. > > > Massimo > > > On Jun 19, 3:27 am, "Sebastian E. Ovide" <sebastianov...@gmail.com> > > wrote: > > > I'm looking for a way to use "AS" in a query so that I can rename > > columns... > > > > so for example: > > > rows=db().select(db.mytable.date,db.mytable.clicks.sum(),db.mytable.impressions.sum(),groupby=db.mytable.date) > > > > produces > > > > SELECT mytable.date, SUM(mytable.clicks), SUM(mytable.impressions) FROM > > > mytable GROUP BY mytable.date; > > > > and so I can do > > > > print rows[1].date > > > > but I need to rename the columns... > > > > for example rename SUM(mytable.impressions) as impressions so that I can > > do > > > > print rows[1].impressions > > > > is there any way to do it without using db.executesql ? > > > > On Fri, Jun 19, 2009 at 11:26 AM, mdipierro <mdipie...@cs.depaul.edu> > > wrote: > > > > > yes and no. You can do: > > > > > morehits = db.mytable.myhits.sum() > > > > rows=db().select(db.mytable.mydate,morehits,groupby=db.mytable.mydate) > > > > for row in rows: > > > > print row.mytable.mydate, row._extra[morehits] > > > > > but the morehits does not appear in the actual generated SQL because > > > > there is no need to. > > > > > On Jun 18, 2:15 pm, sebastian <sebastianov...@gmail.com> wrote: > > > > > Hi, > > > > > > is it possible to run this select using DAL ? > > > > > > select date,sum(hits) as morehits from report group by date > > > > > > (see the "as") > > > > > > thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---