Re: [sqlalchemy] Multi-get?

2011-01-27 Thread Yang Zhang
Yeah, that's what we do right now.

On Wed, Jan 26, 2011 at 8:03 PM, Mike Conley mconl...@gmail.com wrote:

 On Wed, Jan 26, 2011 at 8:17 PM, Yang Zhang yanghates...@gmail.com wrote:

 Is there something similar to the .get() method in SqlSoup and Session
 but which allows me to fetch more than one object by ID, so as to save
 on round trips to the DB? (This could be done by composing using the
 IN operator in SQL.) Thanks in advance.

 Did you try something like
    session.query(MyClass).filter(MyClass.id.in_([...list of ids...])).all()


 --
 Mike Conley

 --
 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.




-- 
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.



[sqlalchemy] Multi-get?

2011-01-26 Thread Yang Zhang
Is there something similar to the .get() method in SqlSoup and Session
but which allows me to fetch more than one object by ID, so as to save
on round trips to the DB? (This could be done by composing using the
IN operator in SQL.) Thanks in advance.

-- 
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.



Re: [sqlalchemy] Multi-get?

2011-01-26 Thread Mike Conley
On Wed, Jan 26, 2011 at 8:17 PM, Yang Zhang yanghates...@gmail.com wrote:

 Is there something similar to the .get() method in SqlSoup and Session
 but which allows me to fetch more than one object by ID, so as to save
 on round trips to the DB? (This could be done by composing using the
 IN operator in SQL.) Thanks in advance.


Did you try something like
   session.query(MyClass).filter(MyClass.id.in_([...list of ids...])).all()


-- 
Mike Conley

-- 
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.