On Thu, May 15, 2008 at 3:43 PM, Carlos Hanson <[EMAIL PROTECTED]> wrote: > Greetings, > > I just started playing with declarative_base. I have one table on > which I would like to have a unique contraint on two columns. Is this > possible using declarative? > > -- > Carlos Hanson >
I think there are two solutions. The first is to use a direct Table contruct within the class definition: class MyClass(Base): __table__ = Table('my_class_table', Base.metadata, ... The second is to apply a unique index after the fact: my_index = Index('myindex', MyClass.col1, MyClass.col2, unique=True) I like the first solution, so I'm not going to test the second today. -- Carlos Hanson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---