Re: [SQLObject] SelectResults internal
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ma...> - 2006-08-01 08:32:49
|
On Tue, Aug 01, 2006 at 07:47:48AM +0200, Didrik Pinte wrote: > [1] vdata = validdata.select(AND(validdata.q.stationID == station.id, > validdata.q.mtime == row.mtime))[0] > > then I parse the states in this row with the following code : > > [2] for state in states: > getattr(vdata, state) > > My understanding is that vdata is a SelectResults and that the Wrong. You have used [0] to index the SelectResults object and hence get an SQLObject instance. > getatrr(vdata, state) will just fetch the data from this SelectResults. SelectResults doesn't hold any data itself - it is only a way to get a list of SQLObject instances. You've got an SQLObject instance already, and you fetches data from it. > It seems that for each getattr(vdata, state) there is a new call to the > database. Because you are fetching data via ForeignKey columns, and SQLObject doesn't cache them (but it caches the referenced rows). Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |