Recursive select with web2py
In this article we will deal with a somewhat well-known but unexplained subject. This tip applies not only to web2py but to anyone who needs to organize their data into tree structures using data from the database. http://www.web2py.com/books/default/chapter/31/06/data-abstruction-layer#-Recursive-select-s . db.define_table('thing', Field('name'), Field('owner_id', 'reference person')) The web2py documentation proposes the following table structure and how to recursively select this data. person = db.person(id) for thing in person.thing.select(orderby=db.thing.name): print person.name, 'owns', thing.name The fact is that if we do the db (). Select () command it will create a new database connection and so as many times as needed. If we think of a system that receives several visitors per minute (or second), even a table with little data would overload our application. So which one is ideal? ...