On May 20, 2010, at 5:51 PM, Yang Zhang wrote: > How do I create an ORM type with no primary key columns? For some > reason I'm getting: > > sqlalchemy.exc.ArgumentError: Mapper > Mapper|ActorActivity|actor_activities could not assemble any primary > key columns for mapped table 'actor_activities' > > for: > > class ActorActivity(Base): > __tablename__ = 'actor_activities' > actor_id = Column(UUID, ForeignKey(Actor.id), nullable = > False) > t = Column(SmallInteger, nullable = False) > ts = Column(TIMESTAMP, nullable = False) > a = Column(UUID, ForeignKey(A.id)) > b = Column(UUID, ForeignKey(B.id)) > n = Column(SmallInteger) > x = Column(SmallInteger) > > Thanks for any hints.
the orm has to be given the list of columns that serve as the primary key even if the table doesn't actually have any. FAQ entry here: http://www.sqlalchemy.org/trac/wiki/FAQ#IhaveaschemawheremytabledoesnthaveaprimarykeycanSAsORMhandleit although here you can just put "primary_key=True" on those columns you'd like to consider as PK cols, since you are using declarative and everything is in one place anyway. if the issue is, you want no PK at all, even a python-only one, that's not really possible. The ORM needs a way to locate the row for your instance in the DB in order to issue updates/deletes etc. > -- > Yang Zhang > http://yz.mit.edu/ > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@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. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.