sqlalchemy: how to define association object with declarative style?

Chris Withers chris at simplistix.co.uk
Mon Sep 20 20:29:44 CEST 2010


Hi Jerry,

For SQLAlchemy questions, you're better off asking on 
sqlalchemy at googlegroups.com.

On 07/09/2010 10:39, Jerry Fleming wrote:
> class GroupUser(DeclarativeBase, Tablename, TimestampMixin):
>      id = Column(Integer, Sequence('group_user_id_seq'), primary_key=True)
>      user = Column(Integer, ForeignKey('user.id'), index=True),
>      group = Column(Integer, ForeignKey('group.id'), index=True)
>
> I was wondering how to associate User and Group with GroupUser with
> GroupUser as the association object/proxy? The sqlalchemy docs only
> mention only mention association tables, or non-declarative manual mapping.

Yes, declarative doesn't currently work like this.
The functionality could probably be added, but Michael Bayer would be 
the man to decide how to do that :-)

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
             - http://www.simplistix.co.uk



More information about the Python-list mailing list