Hello again,
I'm running into a new set of errors when I attempt to save objects to
the database, then interrogate their properites. Here is an example
of my latest problem:
I have a very simple class called "Compound" which stores a creation
date, a smiles string (string representation of a chemical compound)
and a username:
class Compound(object):
def __init__(self, crt_date, smiles, username):
self.crt_date = crt_date
self.smiles = smiles
self.username = username
def __repr__(self):
return "<Compound('%s', '%s', '%s')" % (self.smiles,
self.crt_date,
self.username)
The corresponding table is defined as follows:
cpdTbl = Table('compound', meta,
Column('compound_id', Integer,
primary_key=True),
Column('crt_date', DateTime,
PassiveDefault('sysdate'),
nullable=False),
Column('smiles', String(4000), index=True,
unique=True,
nullable=False),
Column('username', String(4000))
)
The mapping looks like this:
mapper(Compound, self.cpdTbl, properties={
'comments':relation(CompoundComment, backref='compound'),
'names':relation(CompoundName, backref='compound',
lazy=False),
'properties':relation(Property,
secondary=self.cpdPropAssoc,
lazy=False),
'submission':relation(Submission, backref='compound'),
'xray':relation(Xray, backref='compound')
})
Now, when I issue the following statements, I get the following error:
sess = Session()
cpd = Compound(None, 'CCCCC', 'jroy')
sess.save(cpd)
sess.commit()
print str(cpd)
(Note that crt_date is initially set to 'None', as crt_date is auto-
generated by the database upon insertion of a record).
"C:\Python24\lib\site-packages\sqlalchemy-0.4.0beta6-py2.4.egg
\sqlalchemy\orm\attributes.py", line 40, in __get__
File "C:\Python24\lib\site-packages\sqlalchemy-0.4.0beta6-py2.4.egg
\sqlalchemy\orm\attributes.py", line 242, in get
File "C:\Python24\lib\site-packages\sqlalchemy-0.4.0beta6-py2.4.egg
\sqlalchemy\orm\strategies.py", line 205, in lazyload
TypeError: unsubscriptable object
Any ideas about what could be going wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---