Re: [SQLObject] Having trouble with one to many joins
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <el...@in...> - 2003-06-16 22:14:32
|
Andy, > Table 1 (the parent) is called PORTFOLIOS, here is my class definition; > > class Portfolio(SQLObject): > _table='portfolios' > _columns=[Col('portfolioCode'), > Col('portfolioDesc'), > ] > _joins=[MultipleJoin('Holding'), > ] > > The child table is called HOLDINGS, here is its class definition; > > class Holding(SQLObject): > _table='holdings' > _columns=[Col('portfolioID', foreignKey='Portfolio'), > Col('stockID', foreignKey='Stock'), > Col('buyDate'), > Col('buyQuantity'), > Col('buyPrice'), > Col('currentQuantity'), > ] I think you're having a problem with table names. The portfolio object is going to expect a table named "holding", based on the class definitions above. The portfolio holdings will then be available via the attribute ".holdings" You need to change the name of table holdings to "holding", or explicitly specify the table's name in the portfolio class definition. You may also want to explicitly name the join column's name if you do the latter. I've found that under certain circumstances (can't remember what), SO will incorrectly guess the join column names if you explicitly name the other tables. ...Edmund. |