[sqlalchemy] Re: simple many-to-many select

2007-04-05 Thread Ram Yalamanchili

was filter_by added recently? I have a assign_mapped class User from
TG, and doing a session.query(User).filter_by doesn't work (no such
method).

On 4/4/07, Michael Bayer [EMAIL PROTECTED] wrote:

 My preference with assign_mapper at this point is to say:

 Client.query.filter_by(sites=siteobj)

 i.e. i dont think constantly adding methods to assignmapper is going
 to scale, as the chances of conflicts with existing user classes
 grows.  im into hierarchies of names rather  than huge straight down
 lists.


 On Apr 4, 2007, at 5:40 AM, Alexandre CONRAD wrote:

 
  Glauco wrote:
 
  Alexandre CONRAD ha scritto:
 
  Okay, thanks. Any idea if .filter_by() and other new generative
  method
  will be available in an assign_mapper object?
 
  Yes..it's available, the final object has identical property as  a
  mapper
 
  Well, model.Client.filter_by(sites=siteobj) doesn't work for me...
 
 AttributeError: type object 'Client' has no attribute 'filter_by'
 
  Or am I misunderstanding how to use it ?
 
  Regards,
  --
  Alexandre CONRAD
 
 
  


 


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



[sqlalchemy] Re: simple many-to-many select

2007-04-05 Thread Glauco

Ram Yalamanchili ha scritto:
 was filter_by added recently? I have a assign_mapped class User from
 TG, and doing a session.query(User).filter_by doesn't work (no such
 method).
   


yes, it's in the latest 0.3.6 version...

this sometime it's hopeful :-)




- orm:
- the full featureset of the SelectResults extension has been merged
  into a new set of methods available off of Query.  These methods
  all provide generative behavior, whereby the Query is copied
  and a new one returned with additional criterion added.  
  The new methods include:

  filter() - applies select criterion to the query
  filter_by() - applies by-style criterion to the query
  avg() - return the avg() function on the given column
  join() - join to a property (or across a list of properties)
  outerjoin() - like join() but uses LEFT OUTER JOIN
  limit()/offset() - apply LIMIT/OFFSET
  range-based access which applies limit/offset:  
 session.query(Foo)[3:5]
  distinct() - apply DISTINCT
  list() - evaluate the criterion and return results
  
  no incompatible changes have been made to Query's API and no methods
  have been deprecated.  Existing methods like select(), select_by(),
  get(), get_by() all execute the query at once and return results
  like they always did.  join_to()/join_via() are still there although
  the generative join()/outerjoin() methods are easier to use.



-- 
++
  Glauco Uri - Programmatore
glauco(at)allevatori.com 
   
  Sfera Carta Software®  [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
++



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



[sqlalchemy] Re: simple many-to-many select

2007-04-05 Thread Glauco
Glauco ha scritto:
 Ram Yalamanchili ha scritto:
   
 was filter_by added recently? I have a assign_mapped class User from
 TG, and doing a session.query(User).filter_by doesn't work (no such
 method).
   
 


 yes, it's in the latest 0.3.6 version...

 this sometime it's hopeful :-)
   
ps... i forgot link:   http://www.sqlalchemy.org/CHANGES



 - orm:
 - the full featureset of the SelectResults extension has been merged
   into a new set of methods available off of Query.  These methods
   all provide generative behavior, whereby the Query is copied
   and a new one returned with additional criterion added.  
   The new methods include:

   filter() - applies select criterion to the query
   filter_by() - applies by-style criterion to the query
   avg() - return the avg() function on the given column
   join() - join to a property (or across a list of properties)
   outerjoin() - like join() but uses LEFT OUTER JOIN
   limit()/offset() - apply LIMIT/OFFSET
   range-based access which applies limit/offset:  
  session.query(Foo)[3:5]
   distinct() - apply DISTINCT
   list() - evaluate the criterion and return results
   
   no incompatible changes have been made to Query's API and no methods
   have been deprecated.  Existing methods like select(), select_by(),
   get(), get_by() all execute the query at once and return results
   like they always did.  join_to()/join_via() are still there although
   the generative join()/outerjoin() methods are easier to use.



   


-- 
++
  Glauco Uri - Programmatore
glauco(at)allevatori.com 
   
  Sfera Carta Software®  [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
++



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



[sqlalchemy] Re: simple many-to-many select

2007-04-05 Thread Alexandre CONRAD

Michael Bayer wrote:

 My preference with assign_mapper at this point is to say:
 
 Client.query.filter_by(sites=siteobj)

For the mailing list's archives correctness:

   Client.query().filter_by(sites=siteobj)

 i.e. i dont think constantly adding methods to assignmapper is going  
 to scale, as the chances of conflicts with existing user classes  
 grows.  im into hierarchies of names rather  than huge straight down  
 lists.

I understand. I also think that having it in the query() is a good 
practice. Then maybe the methods directly accessible from Client.x() 
should be set as deprecated ?

Regards,
-- 
Alexandre CONRAD


 On Apr 4, 2007, at 5:40 AM, Alexandre CONRAD wrote:
 
 
Glauco wrote:


Alexandre CONRAD ha scritto:


Okay, thanks. Any idea if .filter_by() and other new generative  
method
will be available in an assign_mapper object?

Yes..it's available, the final object has identical property as  a  
mapper

Well, model.Client.filter_by(sites=siteobj) doesn't work for me...

   AttributeError: type object 'Client' has no attribute 'filter_by'

Or am I misunderstanding how to use it ?

Regards,
-- 
Alexandre CONRAD



 
 
  
 
 
 ---
 Texte inséré par Platinum 2007:
 
  S'il s'agit d'un mail indésirable (SPAM), cliquez sur le lien suivant pour 
 le reclasser : http://127.0.0.1:6083/Panda?ID=pav_33314SPAM=true
 ---
 
 




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



[sqlalchemy] Re: simple many-to-many select

2007-04-04 Thread Alexandre CONRAD

Okay, thanks. Any idea if .filter_by() and other new generative method 
will be available in an assign_mapper object?

http://www.sqlalchemy.org/docs/plugins.html#plugins_assignmapper

I'm figuring out that join_via and join_to will no longer be used as 
it's not documented anymore and will be replaced .join() / .outerjoin().

Regards,
-- 
Alexandre CONRAD


Michael Bayer wrote:
 
 
 On Apr 3, 12:39 pm, Alexandre CONRAD [EMAIL PROTECTED] wrote:
 
And I'd like to find all attachments from one client. But as there's a
weak (secondary) table in between, I can no longer have something like:

   model.Attachment.id_client==c.client.id

How can I achieve this ?
 
 
 using a criterion like
 and_(Attachment.c.attachment_id==attachment_has_clients.c.id_attachment,
 attachment_has_clients.c.id_client=Client.c.cllient_id)
 
 or you could use the built in stuff:
 
 session.query(Attachment).filter_by(clients=someclient).list()
 
 
ps: I'm using assign_mapper.

Regards,
--
Alexandre CONRAD
 
 
 
  
 
 
 ---
 Texte inséré par Platinum 2007:
 
  S'il s'agit d'un mail indésirable (SPAM), cliquez sur le lien suivant pour 
 le reclasser : http://127.0.0.1:6083/Panda?ID=pav_33248SPAM=true
 ---
 
 



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



[sqlalchemy] Re: simple many-to-many select

2007-04-04 Thread Glauco

Alexandre CONRAD ha scritto:
 Okay, thanks. Any idea if .filter_by() and other new generative method 
 will be available in an assign_mapper object?
   

Yes..it's available, the final object has identical property as  a mapper



Glauco

-- 
++
  Glauco Uri - Programmatore
glauco(at)allevatori.com 
   
  Sfera Carta Software®  [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
++



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



[sqlalchemy] Re: simple many-to-many select

2007-04-04 Thread Alexandre CONRAD

Glauco wrote:

 Alexandre CONRAD ha scritto:
 
Okay, thanks. Any idea if .filter_by() and other new generative method 
will be available in an assign_mapper object?
 
 Yes..it's available, the final object has identical property as  a mapper

Well, model.Client.filter_by(sites=siteobj) doesn't work for me...

   AttributeError: type object 'Client' has no attribute 'filter_by'

Or am I misunderstanding how to use it ?

Regards,
-- 
Alexandre CONRAD


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



[sqlalchemy] Re: simple many-to-many select

2007-04-04 Thread Michael Bayer

My preference with assign_mapper at this point is to say:

Client.query.filter_by(sites=siteobj)

i.e. i dont think constantly adding methods to assignmapper is going  
to scale, as the chances of conflicts with existing user classes  
grows.  im into hierarchies of names rather  than huge straight down  
lists.


On Apr 4, 2007, at 5:40 AM, Alexandre CONRAD wrote:


 Glauco wrote:

 Alexandre CONRAD ha scritto:

 Okay, thanks. Any idea if .filter_by() and other new generative  
 method
 will be available in an assign_mapper object?

 Yes..it's available, the final object has identical property as  a  
 mapper

 Well, model.Client.filter_by(sites=siteobj) doesn't work for me...

AttributeError: type object 'Client' has no attribute 'filter_by'

 Or am I misunderstanding how to use it ?

 Regards,
 -- 
 Alexandre CONRAD


 


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



[sqlalchemy] Re: simple many-to-many select

2007-04-03 Thread Michael Bayer



On Apr 3, 12:39 pm, Alexandre CONRAD [EMAIL PROTECTED] wrote:

 And I'd like to find all attachments from one client. But as there's a
 weak (secondary) table in between, I can no longer have something like:

model.Attachment.id_client==c.client.id

 How can I achieve this ?

using a criterion like
and_(Attachment.c.attachment_id==attachment_has_clients.c.id_attachment,
attachment_has_clients.c.id_client=Client.c.cllient_id)

or you could use the built in stuff:

session.query(Attachment).filter_by(clients=someclient).list()


 ps: I'm using assign_mapper.

 Regards,
 --
 Alexandre CONRAD


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