Carl, the formatting got a bit messed up but if I read your definition correctly you defined the relation as 'splits'. So you'd want to write "trainingEffor.splits" (lower case 's' in splits).
-sas On Aug 12, 9:20 am, Bleve <carl.i.bre...@gmail.com> wrote: > I'm using SQLAlchemy 0.6.3 on Python 2.6 (win32) > > I have a class, Efforts, which has many splits (time and distance and > some other fluff), so for each training effort, there can be one or > more splits. It has a few other relationships as well, but this is > the important one, or at least, the one I'm stuck on at the moment! > > The definition in my script : > > class Efforts(Base): > __tablename__ = 'efforts' > > id = Column(Integer, primary_key = True) > effortTypeId = Column(Integer, ForeignKey("effortTypes.id"), > nullable=False) > riderId = Column(Integer, ForeignKey("riders.id"), nullable=False) > sessionId = Column(Integer, ForeignKey("trainingSessions.id"), > nullable=False) > . > # stuff trimmed to save space > . > > splits = relationship(Splits, backref='efforts', > order_by=Splits.sequenceNumber) > rider = relationship(Riders, backref='efforts', > order_by=Riders.id) > session = relationship(TrainingSessions, backref='efforts', > order_by= TrainingSessions.id) > > def __init__(self, effortTypeId, riderId, sessionId, distance, > time, maxpower, fiveSecPower, \ > maxTorque, startTime, temperature, pressure, humidity, windSpeed, > comments, timingAccuracy, \ > gearInches, seated, standingStartType, startingSpeed, startingLeg, > riderWeight, bikeWeight, \ > extraWeight, borgRPE): > self.effortTypeId = effortTypeId > self.riderId = riderId > self.sessionId = sessionId > > # stuff trimmed ... > > and the 'splits' definition : > > class Splits(Base): > __tablename__ = 'splits' > > id = Column(Integer, primary_key = True) > effort = Column(Integer, ForeignKey("efforts.id"), nullable=False) > sequenceNumber = Column(Integer, nullable=False, default = 1) > distance = Column(Float, nullable=False) > time = Column(Float, nullable=False) > timingAccuracy = Column(Float, default = 0.1) > > def __init__(self, effort, sequenceNumber, distance, time, > timingAccuracy): > self.effort = effort > self.sequenceNumber = sequenceNumber > self.distance = distance > self.time = time > self.timingAccuracy = timingAccuracy > > I've stuffed something up, because when I create an 'effort' : > > trainingEffort = stDataClasses.Efforts( > effortTypeId = ChosenEffortId,\ > riderId = self.rider.id,\ > sessionId = self.thisSession.id,\ > . > . > . > ) > print trainingEffort > print "splits in trainingEffort :", trainingEffort.Splits > > I should, I think, see a null array when I ask for > trainingEffort.Splits, but instead I see this : > > AttributeError: 'Efforts' object has no attribue 'Splits' > > Can anyone here untangle my mess? My python skill level is still very > much a novice, I've read the SQLAlchemy doco for the ORM but I think > something's just not sinking in. > > Thank you for any pointers in the right direction! > > Carl -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.