From: Ian B. <ia...@co...> - 2003-06-10 02:42:10
|
On Mon, 2003-06-09 at 21:05, Edmund Lian wrote: > Is there anyway to pass pure SQL through to the database? I was thinking > that if performance is an issue, then under some circumstances, it would > be nice to be able to override selected object methods and use pure SQL > to do things, I think. Yes, the connections have a query(sql) method, with no return value. There's also an attribute conn, which is the actual connection object. So long as you aren't using cacheValues, or you aren't modifying rows that could have instantiated SQLObject instances, it shouldn't be a problem. > The specific example I'm thinking of is a situation where a table needs > to have N rows inserted into it, and the data are from other tables. > Right now, I'd have to write a loop to do this, emitting at least N > queries. If I could pass SQL through, I could replace the loop with just > one SQL statement. > > Is this a good idea? That might be easiest. It would be reasonable to support this sort of insertion directly, kind of like .set() updates multiple attributes at once. But I'm not sure how to handle the ID generation, assuming you want a way to get the newly created objects back; maybe it just wouldn't have a meaningful return, and you'd have to retrieve the new objects via .select or some other manner. I don't think that would be too hard to implement. Ian |