On Tue, Apr 26, 2011 at 12:32 PM, Yang Zhang <yanghates...@gmail.com> wrote: > On Wed, Apr 13, 2011 at 6:07 PM, Michael Bayer <mike...@zzzcomputing.com> > wrote: >> To work around the "instance arguments being baked in", create the query >> like this: >> >> query.filter(SomeClass.somerecord ==bindparam("somerecord")) >> >> The params are then added using query.params(somerecord=x). > > Is it possible to use this with .get()? > > Currently, all our > > ...query(Item).get(id) > > become > > q=...query(Item).filter_by(id=bindparam('id')) > q.params(id=id).one() > > We're thinking of having a custom Session and Query that override > Query.get() to build and cache the above query internally, since this > is such a frequently used construct. But we wanted to see if we're > missing anything first.
Actually, this is turning out *slower* than using .get(), by about an order of magnitude. -- Yang Zhang http://yz.mit.edu/ -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.