Michael,

Thanks for getting back to me so quickly. I've figured out how to get a
one-to-many, single table relationship working with one way relations,
here is that configuration:

class JobData(Base):
    __tablename__ = "jobs"
    id       = Column(Integer, primary_key=True, autoincrement=True)
    pid      = Column('pid', Integer, ForeignKey('jobs.id'))
    srcpath  = Column(String(128), default=None)
    press    = Column(Integer, default=None)
    priority = Column(Integer, default=None)
    created  = Column(DateTime, default=datetime.datetime.now)
          
    def __init__(self, srcpath=None):
        session = Session()
        self.srcpath = srcpath
        session.add(self)
        session.commit()

Jobs that are children of other jobs get their pid field initialized,
and this seems to work well.

I wasn't sure if the link you sent was what you intended as that brought
up a page about eager loading. However, it was interesting reading all
the same!

Thanks again,
Doug


> -----Original Message-----
> From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED]
> On Behalf Of Empty
> Sent: Wednesday, September 17, 2008 9:02 AM
> To: sqlalchemy@googlegroups.com
> Subject: [sqlalchemy] Re: Declarative documentation
> 
> 
> Hi Doug,
> 
> > I'm a new user (like this week) of SqlAlchemy and I'm trying to find
> > more information about using the Declarative system. In particular
> I'm
> > trying to build a hierarchical table with one-to-many relationships
> > within the table. So if anyone knows where there might be some
> > additional documentation about this, examples or just some guidance,
> > I'd very much appreciate it!!
> 
> There's extensive documentation online and in the ext/declarative.py
> module itself.  Beyond that it's basically just straight SQLAlchemy.
> So you would be handling a self referential hierarchy as demonstrated
> here:
> 
>
http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_
> selfreferential
> 
> I hope that helps.
> 
> Michael
> http://blog.michaeltrier.com/
> 
> 

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to