Sam, Well, you can do MyClass.select(conditions) which returns instances. If you only want to return a selection of comments, I believe there is a hook to do that; check the docs.
I can understand this may seem strange to you, it certainly did to me in the beginning, but as I built up experience I've found the design is very logical. Your problems come because you're fighting the framework - creating instances manually rather than using MyClass.select(). Paul On 6/22/07, SamDonaldson <[EMAIL PROTECTED]> wrote: > > > Ok, so let me explain the problem we're facing. I'm using turbogears > with sqlalchemy. I run a custom query by supplying the SELECT string > to the engine and then execute() that. It returns back a list of > tuples. I'd like it to return a bunch of instances of A but I can't > seem to find the api to do that. Note that I'm not selecting > everything, just a few columns. So, I wrote my own constructor which > basically runs through the tuple list and constructs instances of > class A and then returns that list back to my controller. > > The problem is that when I'm exiting my controller, I find that I get > a duplicate key error because it seems like the controller in > turbogears tries to commit unsaved objects (the ones I manually > created for better access in my code). Why is this? How do I turn > this off? I used session.clear() and it seemed to work but I'm not > comfortable using this. Why can't I just create objects and not have > turbogears force commit them? > > Any help would be appreciated here in understanding sessions and how > they work. Is there an api that can be used to convert tuples into > instances? > > Thanks. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---