In the FAQ, in response to the Q "How do I map a table that has no primary 
key? 
<http://docs.sqlalchemy.org/en/rel_0_9/faq.html#how-do-i-map-a-table-that-has-no-primary-key>"
 
, it says:


...the best candidate key can be applied directly to the mapper:

class SomeClass(Base):
    __table__ = some_table_with_no_pk
    __mapper_args__ = {
        'primary_key':[some_table_with_no_pk.c.uid, some_table_with_no_pk.c.bar]
    }

Better yet is when using fully declared table metadata, use the 
primary_key=True flag on those columns:

class SomeClass(Base):
    __tablename__ = "some_table_with_no_pk"

    uid = Column(Integer, primary_key=True)
    bar = Column(String, primary_key=True)


Two Questions:

1) Is there a way to declare a compound primary key using the fully 
declared table metadata?

2) Why, in a nutshell, is using a fully declared table metadata is 
"better"?  


Thanks!

-Dan 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to