I've been learning SQLAlchemy and wanted to model of "Users" where they can 
add "friends" and any additions populate across all users. I pulled my hair 
out yesterday because I could get it to work in one direction, but not 
bi-directionally. This seems like such a simple thing (it's easily done in 
the Django ORM). 

The use would be something like this:

jobs = Person(name='Steve Jobs') 
woz = Person(name='Steve Wozniak') 
ive = Person(name='Johnny Ive') 

jobs.friends = [woz, ive]

>>> jobs 
Out[1]: <Person (Steve Jobs)> 

>>> jobs.friends 
Out[2]: [<Person (Steve Wozniak)>, <Person (Johnny Ive)>]

>>> woz.friends 
Out[3]: [<Person (Steve Jobs)>]



I found Mike's answer to this problem: 

- http://www.mail-archive.com/sqlalchemy%40googlegroups.com/msg26262.html
- 
http://stackoverflow.com/questions/9116924/how-can-i-achieve-a-self-referencing-many-to-many-relationship-on-the-sqlalchemy


These posts are from 2012. Has there been any development on these kinds of 
relationships or are Mike's answers still the best known solutions?

Best,
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to