mik wrote: > Hello, > > I am trying to use sqlalchemy with oracle, here is my code: > > from sqlalchemy import * > from sqlalchemy.orm import sessionmaker, mapper, relationship > class Activite(object): > pass > class Famprod(object): > pass > engine = create_engine('oracle://login/paswd@db', echo=True) > metadata = MetaData(engine) > tActivite = Table('ACTIVITE', metadata, > autoload=True) > mapper(Activite, tActivite) > tFamprod = Table('FAMPROD', metadata, > autoload=True) > mapper(Famprod, tFamprod) > Famprod.activite = relationship(Activite) > Session = sessionmaker(bind=engine) > session = Session() > famprod = session.query(Famprod).get(("ED", "15")) > print famprod.activite > > > and i get this error: > AttributeError: 'RelationshipProperty' object has no attribute > 'parent' > > The table famprod has a composite key, one of the key columns is the > key of activite. > Is there something wrong with my code ? > I have tried to manually define the tFamprod's keys and foreign key > without succes. > > Thank you. >
I think your problem is here: mapper(Famprod, tFamprod) Famprod.activite = relationship(Activite) You can't add relationship properties to mapped classes, unless they were set up with the declarative extension (http://www.sqlalchemy.org/docs/orm/extensions/declarative.html). Without declarative, the code should look something like this: mapper(Famprod, tFamprod, properties={ 'activite': relationship(Activite), }) (http://www.sqlalchemy.org/docs/orm/relationships.html#one-to-many) Hope that helps, Simon -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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.