[SQLObject] defining 1 to many relationships
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <jo...@cy...> - 2004-02-23 21:53:28
|
Dear Group,
i just started looking at SQLObject and i ahve a question. I am trying to see if it will work with a database that I already have developed with data in MySQL. I have two tables images and di (donating investigator) and there is a 1 to many relationship between di and images. The images table contains a field called source_di which links to the di id field which is also the key for the di table. i defined the table classes like this:
class Images(SQLObject):
_idName = 'uin'
_fromDatabase = True
sourceDi = ForeignKey('Di')
class Di(SQLObject):
_fromDatabase = True
_idName = 'id'
Images = ForeignKey('Images')
When I try and run
images = Images.select()
for i in images:
print i.uin
but this does not work, and the error message says that there is no column called imags.source_di_id
am I out of luck unless I want to redesign the database?
Thanks for any and all help
Jose
|