Re: [SQLObject] How do I insert values into a JOIN table?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Oleg B. <ph...@ma...> - 2006-04-15 14:30:01
|
On Fri, Apr 14, 2006 at 06:23:54PM -0700, Steve Quezadas wrote:
> class TableB(SQLObject):
> VarC = StringCol()
> VarD = ForeignKey("TableA")
>
> TableB.createTable()
>
> 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
What do you want to have here? If you want the DB tests if the .id is
really an id from the table A verify that SQLObject created table B with
all necessary declarations related to referential integrity, FOREIGN KEY in
this case. I don't remember if SQLObject 0.7 does that - I use the latest
SQLObject from 0.7.1 branch.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ ph...@ph...
Programmers don't die, they just GOSUB without RETURN.
|