Re: [sqlalchemy] Autocreate parent while inserting child

2011-06-22 Thread Fayaz Yusuf Khan
On Monday, June 20, 2011 07:34:42 PM Michael Bayer wrote: SQLA doesn't automatically create any objects so you'd need to create the Parent object yourself, but you'd also use relationship(): class Child(Base): parent_name = Column(String, ForeignKey('parent.name')) parent =

Re: [sqlalchemy] Autocreate parent while inserting child

2011-06-22 Thread Michael Bayer
On Jun 22, 2011, at 2:53 AM, Fayaz Yusuf Khan wrote: On Monday, June 20, 2011 07:34:42 PM Michael Bayer wrote: SQLA doesn't automatically create any objects so you'd need to create the Parent object yourself, but you'd also use relationship(): class Child(Base): parent_name =

[sqlalchemy] Autocreate parent while inserting child

2011-06-18 Thread Fayaz Yusuf Khan
Hi, I'm a SQLA and MySQL noob. I have a many to one relationship somewhat similar to this: class Parent(Base): ... name = Column(String, primary_key=True) class Child(Base): ... parent = Column(String, ForeignKey('Parent.name')) And I'm trying to do this: session.add(Child(...,