I used to have: .set(**kw) .update(whereclause, **kw) # this does table.update().execute() .count(whereclause) # table.count(whereclause).scalar() .delete_one(id) .load(*args) # returns a mapper with a bunch of eager loads .add_properties(dict)
Luckily, great minds think alike and I was able to ditch count and add_properties when I upgraded from 0.1.7 to the 0.3 series. The .load() method is very handy and I think other people might find it useful: @classmethod def load(cls, *args): loads = [eagerload(prop) for prop in args] return cls.options(*loads) It fits my usage patterns well, at least (which is to define everything as lazy-load relations and use .load() to eager load them when it makes sense). shoe On 6/1/07, Christoph Haas <[EMAIL PROTECTED]> wrote: > > > On Fri, Jun 01, 2007 at 10:50:33AM -0700, David Shoemaker wrote: > > Both > > session.query(User).select() > > and > > User.query().select() > > seem more verbose than they need to be for my taste. However, I think > most > > people (myself included) define a base class for all their mapped > classes. > > Uhm, that (few) people I know just use assign_mapper as demonstrated in > the many tutorials. Even myself. And now that you mention it I like the > idea. Not duplicating what SA is providing but rather making your own > life easier. > > > I've always used this base class to provide the interface I want, no > > matter what interface sqlalchemy provides > > Now I'm curious. Could you share your base class? > > > That said, if I was new to sqlalchemy, I think I'd be scared to see > > session.query(User).select() as the "recommended way" in the tutorial. > > From lurking on IRC I'm sure most people are indeed scared by SA. :) > > Christoph > > > > > -- --- I'd give my right arm to be ambidextrous. --- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---