Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 7:17 PM, Carlus wrote: I was afraid that was the only solution, but how to delete and insert new row with the relationships of the old one? it doesn't seem like you have to. your Person refers to accomodation.id, and you aren't deleting from that table, only UPDATEing the "type".

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Carlus
I was afraid that was the only solution, but how to delete and insert new row with the relationships of the old one? El viernes, 8 de mayo de 2015, 23:59:28 (UTC+2), Michael Bayer escribió: > > > > On 5/8/15 5:09 PM, Carlus wrote: > > Yes exactly, imagine and hotel vanish, and it became into

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 5:09 PM, Carlus wrote: Yes exactly, imagine and hotel vanish, and it became into an apartment, i know is a weird situation but the code is just an example. OK so the ORM doesn't support an object changing into a new class in place. You have to emit the UPDATE that you want, and sinc

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Carlus
Yes exactly, imagine and hotel vanish, and it became into an apartment, i know is a weird situation but the code is just an example. example, we have these records: Person table: id = 1, person_name = "john", accommodation_id =1 accommodation table: accommodation_id =1 accommodation_type = "hot

Re: [sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Mike Bayer
On 5/8/15 2:41 PM, Carlus wrote: Hello, Sorry I couldnt find info about in google neither in the documentation, I have a model structure like this one: class Person(Base): __tablename__ ='person' id = Column(Integer, primary_key=True, nullable=False) person_name = Column(String, nul

[sqlalchemy] Updating records and keeping the relationships

2015-05-08 Thread Carlus
Hello, Sorry I couldnt find info about in google neither in the documentation, I have a model structure like this one: class Person(Base): __tablename__ = 'person' id = Column(Integer, primary_key=True, nullable=False) person_name = Column(String, nullable=False) accommodation_i