On Feb 19, 10:41 pm, mdipierro <[email protected]> wrote:
> This should do it:
>
> src=db.hosts.with_alias('src')
> dst=db.hosts.with_alias('dst')
> rows=db(db.transmissions.src==src.id)
> (db.transmissions.dst==dst.id).select(src.ALL, dst.ALL)
>
> print rows

Thanks Massimo,
unfortunately does not works,
the SQL generated is:

SELECT src.dns_hostname, dst.dns_hostname, transmissions.data FROM
dst, src, transmissions WHERE (transmissions.src=src.id AND
transmissions.dst=dst.id);
meanwhile the correct line should be:
SELECT src.dns_hostname, dst.dns_hostname, transmissions.data FROM
hosts AS dst, hosts AS src, transmissions WHERE
(transmissions.src=src.id AND transmissions.dst=dst.id);

in the controller I wrote:
query=db(db.transmissions.src==src.id)
(nws_db.transmissions.dst==dst.id).select(src.dns_hostname,
dst.dns_hostname, transmissions.data)

Do you know where is the error?

thank you very much.
Angelo

>
> On Feb 19, 2:57 pm, angleto <[email protected]> wrote:
>
> > Hi,
> > I have a db like this:
>
> > db.define_table("hosts",
> >       SQLField("dns_hostname", "string", notnull=True,
> > default=None,unique=True))
>
> > db.define_table("transmissions",
> >       SQLField("src",  db.hosts),
> >       SQLField("dst", db.hosts),
> >       SQLField("data", "integer", notnull=True, default=None))
>
> > db.transmissions.src.requires=IS_IN_DB(db,
> > 'hosts.id','hosts.dns_hostname')
> > db.transmissions.dsr.requires=IS_IN_DB(db,
> > 'hosts.id','hosts.dns_hostname')
>
> > I'm unable to print the table transmissions resolving the foreign keys
> > src and dst.
> > Somebody can help me?
> > thanks in advance
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to