I have 2 tables:
class ModelAttributeValue(Base):
__tablename__ ='model_attribute_value'
id = Column(Integer,primary_key=True)
model_attribute_id = Column(Integer,ForeignKey('model_attribute.id'))
value= Column(Numeric)
class ModelAttribute(Base):
__tablename__ ='model_attribute'
id = Column(Integer,primary_key=True)
confirmed = Column(Boolean,default=False, nullable=False)
How to insert record to table model_attribute_value and model_attribute in one
transaction?
begin:
insert into table model_attribute(confirmed) values (True)
insert into table model_attribute_value(value,model_attribute_id) values
(1,(select max(id) from model_attribute ))
commit
?
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.