Found the stuff in the FAQ on sqlobject.org about how to do compound
keys....my issue is close to this:
I have a table with two keys, and it is a many to many relationship. The
keys are both have forein key constraints with other tables in the schema.
The primary key of this table is defined as a compound key made up of both
fields...
After looking through the faq, and thinking a bit, I cobbled some code
together which does not seem to work. Help?
This is my current sqlobject:
class FileIndex(SQLObject):
class sqlmeta:
table =3D 'file_index'
idName =3D 'file_name'
idType =3D str
fromDatabase =3D True
#cacheValues =3D False
def _init(self):
SQLObject._init(self)
self._SFIR=3DSOFileIndexRecord(self)
def _get_SFIR(self):
return self._SFIR
class SOFileIndexRecord(object):
def __init__(self, so):
self._so=3Dso
def _get_code(self):
return self._so.code
def _set_code(self, value):
self._so.code=3Dvalue
testCode=3Dproperty(_get_code, _set_code)
def _get_fileName(self):
return self._so.fileName
def _set_fileName(self, value):
self._so.fileName=3Dvalue
fileName=3Dproperty(_get_fileName, _set_fileName)
This is the table as it stands according to my schema:
create table file_index (
code varchar REFERENCES metainfo (code),
file_name varchar REFERENCES files (file_name),
PRIMARY KEY (code, file_name) );
|