title: sqlalchemy, using check constraints
body: <p>I just started on sqlalchemy and I want to put a check constraint on one of my columns. I have a column called <code>startTime</code> and <code>endTime</code> and I want to ensure that <code>endTime &gt; startTime</code>.</p>
  
  <pre><code>from sqlalchemy import Column, Integer, String, ForeignKey, Date
  import models.Base
  
  class Session(Base):
      __tablename__ = 'sessions'
  
      sid = Column(Integer, primary_key=True)
      uid = Column(Integer, ForeignKey('users.uid'), nullable=False)
      startTime= Column(Date, nullable=False)
  
      #probably won't work
      endTime = Column(Date, CheckConstraint('endTime &gt; startTime'), nullable=False)
  </code></pre>