FWIW, this is what I ended up doing (for anyone's future reference):
in controller:
data = db(db.table1.field1=value).select(db.table1.field1,
db.table1.field2)
for (i, row) in enumerate(data):
lookupvalue = row.table1.field2
data[i].field3 = db2.table2(field2=lookupvalue).field3
return dict(data=data)
to show results in view:
for row in data:
{{ =row.table1.field2 }}
{{ =row.field3 }}
-Jim
On Dec 2, 6:32 am, Jim Gregory <[email protected]> wrote:
> What's the easiest way to construct my own rows object from data
> across two databases? Can I create a class that inherits from the
> Rows class? Or is there something even simpler?
>
> -Jim
>
> On Dec 1, 6:15 pm, Vinicius Assef <[email protected]> wrote:
>
>
>
>
>
>
>
> > I think you have to define 2 db objects.
>
> > 1) Retrieve data from db1.
> > 2) For each row, retrieve data from db2 and construct your own rows object.
>
> > But maybe somebody has a better solution.
>
> > --
> > Vinicius Assef.
>
> > On Thu, Dec 1, 2011 at 9:40 PM,JimGregory<[email protected]> wrote:
> > > I have a legacy database that my app needs to connect to. The data in
> > > my app's table has a many-to-one relationship with the data in the
> > > legacy database's table. I'd like to retrieve records from my app's
> > > table plus the data associated with that record from the legacy
> > > database's table at the same time. What's the best way to do this?
> > > It doesn't appear I can make joins across databases.