4 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Understanding relati...
FromSent OnAttachments
maxi20 Feb 2008 06:38 
svilen20 Feb 2008 07:12 
jason kirtland20 Feb 2008 08:13 
maxi21 Feb 2008 05:13 
Subject:[sqlalchemy] Re: Understanding relations list
From:maxi (maxi@gmail.com)
Date:02/21/2008 05:13:46 AM
List:com.googlegroups.sqlalchemy

Hi, thanks for reply

Maybe I wasn't so clear - of course, my english is very bad :( -

Anyway, I will try to expose this with an example

I've an users master table with address detail table (like SA doc), then the mapper is:

mapper(User, users_table, properties={ 'addresses':relation(Address) )

First, I retrive users (and address) from database

user_list = session.query(User).filter_by().all()

Now, I read a specific address from user_list.addresses list through some custom function

addr1 = get_address(user_list.addresses, id=2) # get address id = 2

Then, I do some changes to addr1 and after I want to put this obj (addr1) into user_list.addresses again, in other words, I wanna update addresses list with addr1 object which already exist in that list.

If I do, user_list.addresses.append(addr1), how this works in this case? Search addr1 in addresses list and if exists update this?

Of course, I use session.save_or_update(user_list).

Furthermore, I can insert new addresses in user_list.addresses list too.

I hope be a little more clear.

Regards. M.