views:

70

answers:

3

Let's say I create a table like this:

table = Table('mytable', metadata,
   Column('a', Integer, primary_key=True),
   Column('b', Integer, primary_key=True),
)
table.create()

Is it guaranteed that the primary key will be (a,b) and not (b,a)?

A: 

Yes. It will be a really bad thing if resulting DDL wasn't giving consistent results.

Pavel Repin
+1  A: 

USe echo=True and compare yours with a swapped version? That should give the answer.

Sebastian Pipping
+2  A: 

its guaranteed, yes, since Column objects in Table are ordered. or if you really want to be explicit, use PrimaryKeyContraint().

zzzeek