No, it generates one row by each thumbnail, like:

[{'rolic': {'id':1, 'name':'name1'}, thumbnails: [{'id':1,
image:'...'}]},
{'rolic': {'id':1, 'name':'name1'}, thumbnails: [{'id':2,
image:'...'}]}....

So, I think, this problem impossible to solve by SQL. Just by Python.
Thx

On 22 янв, 09:16, Massimo Di Pierro <[email protected]>
wrote:
> I think:
>
> rows = db(db.thumbnails.rolic_id==db.rolic.id).select()
> rows =
> [{'rolic':row.rolic.as_dict(),'thumbnail':row.thumbnail.as_dict()} for
> row in rows]
>
> this may work too but I am not sure:
>
> rows = db(db.thumbnails.rolic_id==db.rolic.id).select().as_dict()
>
> give it a try.
>
> Massimo
>
> On Jan 21, 6:34 pm, LightOfMooN <[email protected]> wrote:
>
>
>
>
>
>
>
> > db.define_table('rolic',
> >     Field('name', 'string')
> >     )
> > db.define_table('thumbnails',
> >     Field('rolic_id', db.rolic),
> >     Field('image', 'upload')
> >     )
>
> > Is there a way to make SQL Query to get results like this?
>
> > [{'rolic': {'id':1, 'name':'name1'}, thumbnails: [{'id':1,
> > image:'...'}, {'id':2, image:'...'}]},
> > {'rolic': {'id':2, 'name':'name2'}, thumbnails: [{'id':3,
> > image:'...'}, {'id':4, image:'...'}, {'id':5, image:'...'}]}]
>
> > thx

Reply via email to