On Wed, Jul 29, 2009 at 4:34 PM, Lukasz Szybalski<szybal...@gmail.com> wrote: > Hello, > How can I do > Index('myindex', xyz.c.type, xyz.c.name, unique=True) > > in a declarative way? > > class xyz(DeclarativeBase): > __tablename__ = 'xyz' > > #{ Columns > > type = Column(Unicode(), nullable=False) > name = Column(Unicode(), nullable=False)
__table_args__ = (ForeignKeyConstraint(...),UniqueConstraint(...),{}) Actually I needed a primary key on both fields. type = Column(Unicode(), nullable=False, primary_key=True) name = Column(Unicode(), nullable=False,primary_key=True , name="PK_xyz") Now I wonder if name will name my primary key? Do I specify auto_increment=No ? What are the advantages of using declarative way of setting table definitions? vs addressbook_table = sqlalchemy.Table("Addressbook", metadata, sqlalchemy.Column('Address_Sid', sqlalchemy.Integer, primary_key=True), sqlalchemy.Column('FirstName', sqlalchemy.Unicode(40),nullable=False), .... class Addressbook(object): def __init__(self, **kw): """automatically mapping attributes""" for key, value in kw.iteritems(): setattr(self, key, value) mapper(Addressbook, addressbook_table) It seems to me as its harder to find information on proper syntax then it is with regular table, py object, mapper? Lucas > > > how do I do index declarative style? > > Thanks, > Lucas > > > > -- > Using rsync. How to setup rsyncd. > http://lucasmanual.com/mywiki/rsync > OpenLdap - From start to finish. > http://lucasmanual.com/mywiki/OpenLdap > -- Using rsync. How to setup rsyncd. http://lucasmanual.com/mywiki/rsync OpenLdap - From start to finish. http://lucasmanual.com/mywiki/OpenLdap --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---