[SQLObject] How do I insert values into a JOIN table?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Stever <st...@tr...> - 2006-04-15 01:20:08
|
Hello,
I am learning SQLObject and I am wondering how, once a join is created
between two tables to actually INSERT items into the joined table while
respecting referential integrity. Here is my simplified code:
class TableA(SQLObject):
VarA = StringCol(length=10, default="test")
VarB = SingleJoin ("TableB")
class TableB(SQLObject):
VarC = StringCol()
VarD = ForeignKey("TableA")
TableA.createTable()
TableB.createTable()
InsertOne = TableA(VarA = 'foo')
InsertTwo = TableB(VarC=200, VarD=InsertOne.id)
I want it so that if I enter info into TableA, there must also be a
corresponding record in TableB. I would imagine that the value of the
foreign key should automatically be put in whatever values the primary
key is in TableA. Theoretically, I can put anything in VarD, which makes
me somewhat squeemish.
- Steve
|