[web2py] Re: DAL: basic join question

2022-10-27 Thread Dave S
On Wednesday, October 26, 2022 at 5:38:44 PM UTC-7 Jim S wrote:

> Can you try
>
> vrows = db(db.picsntoes.id > 0 ).select(db.pics.ALL, 
> db.picnotes.ALL, left=db.pics.on(db.pics.id == db.picnotes.about))
>
> instead of
>
> vrows = db(db.pics.id == db.picnotes.about).select(db.pics.on(db.pics.id 
> == db.picnotes.about))
>
>
Thank you!  That worked.  And it turns out my version would have worked if 
I hadn't dropped the "join =".  But because of a typo in a text comparison, 
I was actually executing a different query, from before I tried a 
simplified problem.  Now that you've helped my through the simplified 
problem, I can go back and see how far I get in the deeper mud.



If that doesn't work, can you share you're whole model?  Seems like the 
> picnotes def is off a bit.
>
> -Jim
>

Dave S
/dps

> [original post elided]
>>
>  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/26621102-1b40-492a-a5d1-830a01ae4033n%40googlegroups.com.


[web2py] Re: DAL: basic join question

2022-10-26 Thread Jim S
Can you try

vrows = db(db.picsntoes.id > 0 ).select(db.pics.ALL, 
db.picnotes.ALL, left=db.pics.on(db.pics.id == db.picnotes.about))

instead of

vrows = db(db.pics.id == db.picnotes.about).select(db.pics.on(db.pics.id == 
db.picnotes.about))

If that doesn't work, can you share you're whole model?  Seems like the 
picnotes def is off a bit.

-Jim

On Wednesday, October 26, 2022 at 4:41:39 PM UTC-5 snide...@gmail.com wrote:

> I have a table called pics and a table called picnotes, where the 
> definitions are like
>
> db.define_table("pics", Field(...))
> db.define_table("picnotes", Field("about", 'reference pics', Field("note", 
> "string"))
>
> And I want to extract all rows of pics that have a note referring to them 
> (this is a simplified version of what I really want).  I'm trying to follow 
> the book, and double-checking with posts in this group (and peeking at the 
> p4web group), but I keep getting the error
>
>  near "<": syntax error
>
> where the traceback goes to
>
> File 
> "C:\Users\Dave\web2py_src\web2py_src-2.22.5\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  
> line 468, in execute
> rv = self.cursor.execute(command, *args[1:], **kwargs)
>
> and the variables in that frame include
>
> command'SELECT "badpic"."id", "badpic"."iurl", "badpic"ND  ("badpic"."id" = "badpicnote"."about")>);'
> args('SELECT "badpic"."id", "badpic"."iurl", "badpic"ND  ("badpic"."id" = "badpicnote"."about")>);',)
>
> I've tried
>
> vrows = db(db.pics.id == db.picnotes.about).select(db.pics.ALL)
>
> and
>
> vrows = db(db.pics.id == db.picnotes.about).select(db.pics.on(db.pics.id 
> == db.picnotes.about))
>
> What do I need to do instead?
>
> version stuff:
>
>
> web2py™
> Version 2.22.5-stable+timestamp.2022.06.04.18.13.51
> Python
> Python 3.10.7: 
> C:\Users\Dave\AppData\Local\Programs\Python\Python310\python.exe (prefix: 
> C:\Users\Dave\AppData\Local\Programs\Python\Python310)
>
>
> Thanks.
>
> /dps
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/83d899be-f863-4df8-a645-4d5c2457ad68n%40googlegroups.com.