In sqlalchemy 0.5 i have a table defined like this one:
orders = Table('orders', metadata,
Column('id', Integer, primary_key=True),
Column('responsable', String(255)),
Column('customer', String(255)),
Column('progressive', Integer),
Column('date', Date),
Column('exported', Boolean()),
)
Is it possible to define only the customer and year of the date as unique ?
The year isn’t a column only a part of a date but it could be nice to have the year of the date and the customer to be a single key of the table.
Is it possible in sqlalchemy 0.5 ?
Thanks
Without splitting the date field into a month field, a date field, and a year field, there really isn’t a way to do what you’re asking. It would (probably) be easier and simpler for you to include the whole date (month/day/year) in the composite primary; if (id, year) uniquely defines a record, then so will (id, date).