This should work in the normal console but it is a known problem in
the web based shell. There is some timeout issue that closes the DB. I
will investigate more.

On Mar 13, 10:22 am, Jose <[email protected]> wrote:
> Hi,
>
> if I have the following:
>
> db.define_table('master',
>     Field('name')
> )
>
> db.define_table('detail',
>     Field('master', db.master),
>     Field('a_field')
> )
>
> if db(db.master.id>0).count() == 0:
>     db.master.insert(name='A')
>     db.master.insert(name='B')
>     db.master.insert(name='C')
>
> if db(db.detail.id>0).count() == 0:
>     db.detail.insert(master=1, a_field='AA')
>     db.detail.insert(master=1, a_field='AB')
>     db.detail.insert(master=1, a_field='AC')
>
>     db.detail.insert(master=2, a_field='BA')
>     db.detail.insert(master=2, a_field='BB')
>     db.detail.insert(master=2, a_field='BC')
>
>     db.detail.insert(master=2, a_field='CA')
>     db.detail.insert(master=2, a_field='CB')
>
> in the shell do:
>
> >>> a = db.master[1]
> >>> a
>
> <Row {'update_record': <function <lambda> at 0x37f8fc34>, 'name': 'A',
> 'id': 1, 'delete_record': <function <lambda> at 0x37f8f80c>, 'detail':
> <gluon.sql.Set object at 0x380c0cac>}>
>
> >>> b = a.detail
> >>> b.select()
>
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
>   File "/usr/home/jose/w2p/gluon/sql.py", line 3056, in select
>     rows = response(query)
>   File "/usr/home/jose/w2p/gluon/sql.py", line 3051, in response
>     db._execute(query)
>   File "/usr/home/jose/w2p/gluon/sql.py", line 895, in <lambda>
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> ProgrammingError: Cannot operate on a closed database.
>
> How do I get the detail records?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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