I did something like this with

class Document():
    __module__ = __name__
    __tablename__ = 'documents'
    __table_args__ = (UniqueConstraint('number', 'date'), {} )

   id = Column(... ...)


But you need to go a step further to link this to year rather than
date - perhaps you need to have a new column 'year'

Hope this helps
Merv

On Oct 2, 5:04 pm, Joril <jor...@gmail.com> wrote:
> On 2 Ott, 10:42, Joril <jor...@gmail.com> wrote:
>
> > I have a class "Document" with attributes "Number" and "Date", is
> > there a way to set a UniqueConstraint on "Number + year(Date)"?
>
> Self-followup: should I use a unique Index instead? But how do you
> create a functional index in SQLAlchemy?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to