Autoloading ManyToMany association table

10 views
Skip to first unread message

Matt Bodman

unread,
Sep 26, 2011, 1:18:07 AM9/26/11
to sqlal...@googlegroups.com
I am autoloading an MSSQL db.  There are a few ManyToMany assoc tables.  I'm not sure how to map everything.  Here's a typical example of how they look in the db:

Table:  tbUsersToGroups
PK:     ID_UserToGroup
FK:     User_ID
FK:     Group_ID

So I can successfully autoload that assoc table and the Users and Groups tables like this per below, but everything I've tried to link them all has failed.

class UserToGroup(Base):
    __tablename__ = 'tbUsersToGroups'
    __table_args__ = {'autoload':True,'extend_existing':True,'schema':'dbo'}

and

class User(Base):
    __tablename__ = 'tbUsers'
    __table_args__ = {'autoload':True,'schema':'dbo'}

and

class Group(Base):
    __tablename__ = 'tbGoups'
    __table_args__ = {'autoload':True,'schema':'dbo'}

Any help would be great.

Reply all
Reply to author
Forward
0 new messages