On Sep 29, 2008, at 8:03 AM, Nick Murdoch wrote:

>
> What I need to do instead, with no Articles table, is store in
> user_articles_table  the user_id and article_id as I would usually,
> but also have  user.articles  available as a list of integers (or some
> wrapper that provided the integers).
>
> Example:
>
>>>> user = session.query(User).getFirst()
>>>> user.user_id
> 1
>>>> user.articles
> [1, 294, 239, 390, 20, 489, 9378]
>>>> user.articles.append(1000)
>>>> session.commit() # INSERT INTO user_articles (user_id,  
>>>> session_id) VALUES (1, 1000);
>
>
> Is this possible using SQLAlchemy? I'm aware I could simply perform
> inserts and selects manually on the user_articles_table, but I'd quite
> like SA to take care of that for me if at all possible.
>

we have the "wrapper" thing, its the associationproxy.   docs are  
here:  http://www.sqlalchemy.org/docs/04/plugins.html#plugins_associationproxy 
   .

In this case you'd probably map a class to the user_articles_table and  
use associationproxy to create user.articles against "article id".

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

Reply via email to