On Feb 20, 4:16 pm, mdipierro <[email protected]> wrote:
> Sorry, try:
>
> src=db.hosts.with_alias('src')
> dst=db.hosts.with_alias('dst')
> rows=db().select(src.ALL,dsl.ALL,left=[src.on
> (db.transmissions.src==src.id), dst.on(db.transmissions.dst==dst.id)])
> print rows

the first one works.
Thanks a lot.
A.

>
> and
>
> src=db.hosts.with_alias('src')
> dst=db.hosts.with_alias('dst')
> rows=db().select(db.transmission.ALL,src.ALL,dsl.ALL,left=[src.on
> (db.transmissions.src==src.id), dst.on(db.transmissions.dst==dst.id)])
> print rows
>
> On Feb 20, 3:49 am, angleto <[email protected]> wrote:
>
> > 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