ignore my previous response to this. The value for your composite primary
key columns would originate from the values present in the corresponding
row in the activity_log and members tables.  If you'd like SQLa to handle
that automatically, you'd have to make usage of the relation() function to
organize that relationship within the ORM.

Also slightly unrelated, the ForeignKeyConstraint you have below isn't
going to be picked up by declarative since it's not part of
__table_args__.


Gloria W wrote:
>
> Hi again,
> I have this table, which has a composite primary key, and no sequence:
>
> # \d log_members
>     Table "public.log_members"
>    Column   |  Type   | Modifiers
> ------------+---------+-----------
>  memberID   | integer | not null
>  logentryID | integer | not null
> Indexes:
>     "log_members_pkey" PRIMARY KEY, btree ("memberID", "logentryID")
>     "logentryID_index" btree ("logentryID")
>     "memberID_index" btree ("memberID")
> Foreign-key constraints:
>     "logtypeID_fk" FOREIGN KEY ("logentryID") REFERENCES activity_log
> ("logentryID") ON DELETE CASCADE
>     "memberID_fk" FOREIGN KEY ("memberID") REFERENCES members
> ("memberID") ON DELETE CASCADE
>
> I was able to accommodate the composite key easily, but default
> SqlAlchemy models want a sequence number to bump upon insert. How do I
> handle this in SqlAlchemy?
>
> My model code:
>
> class LogMember(Base):
>         """
>         Class which ties activity log entries to member ids.
>         """
>         __tablename__ = 'log_members'
>
>         logentryID = Column(Integer,primary_key=True)
>         member_id = Column(Integer,primary_key=True,name='memberID')
>         ForeignKeyConstraint(['logentryID', 'member_id'],
> ['activity_log.logentryID', 'members.memberID'])
>
>         def __init__(self,logentryID,memberID):
>                 self.logentryID = logentryID
>                 self.memberID = memberID
>
>         def __repr__(self):
>                 return "<Affiliation('%s','%s')>" \
>                         % (self.logentryID, self.memberID)
>
>
> Thank you in advance!
> Gloria
>
>
> >
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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