> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:sqlalch...@googlegroups.com] On Behalf Of Sanjay
> Sent: 27 February 2009 05:52
> To: sqlalchemy
> Subject: [sqlalchemy] "Class.query" vs "DBSession.query(Class)"
> 
> 
> Hi,
> 
> There are two styles of writing code for querying: the assignmapper
> style, i.e. "Class.query" vs. the standard style as documented in
> SQLAlchemy tutorial, i.e. "DBSession.query(Class)."
> 
> The assignmapper style seems simpler and intuitive. Curious to know
> why it is not the standard way. Are there any disadvantages?
> 
> Also refer 
> http://groups.google.co.in/group/turbogears/browse_thread/thre
> ad/8f3b4c4da33d69c8
> 
> thanks,
> Sanjay
> 

Class.query can only work if you are using a scoped session, which isn't
appropriate for many kinds of application. Session.query(Class) is
completely general and will work anywhere, and is therefore more
appropriate for use in the documentation.

As the post in the TurboGears thread points out, you can easily add
Class.query using the query_property method of the scoped session.

Simon


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

Reply via email to