title: why UniqueConstraint doesn't work in flask_sqlalchemy
body: <p>I want an alternative of Django's <code>unique_together</code> in flask, seems <code>UniqueConstraint</code> is what I'm looking for, but doesn't work for me.</p>
  
  <p>here is the example:</p>
  
  <pre><code>import os
  from flask import Flask
  from flask_script import Manager, Shell
  from flask_sqlalchemy import SQLAlchemy
  
  basedir = os.path.abspath(os.path.dirname(__file__))
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] =\
      'sqlite:///' + os.path.join(basedir, 'data.sqlite')
  app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  
  manager = Manager(app)
  db = SQLAlchemy(app)
  
  class User(db.Model):
      __tablename__ = 'users'
      __table_args__ = tuple(db.UniqueConstraint('name', 'address'))
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(64), nullable=False)
      address = db.Column(db.String(64), nullable=False)
  
      def __repr__(self):
          return '&lt;User (%s, %s)&gt;' % (self.name, self.address)
  
  
  def make_shell_context():
      return dict(app=app, db=db, user=User)
  manager.add_command("shell", Shell(make_context=make_shell_context))
  
  
  if __name__ == '__main__':
      manager.run()
  </code></pre>
  
  <p>Test it:</p>
  
  <pre><code>$ python test.py shell
  
  In [1]: db.create_all()
  
  In [2]: u1=user(name='a', address='x'); u2=user(name='a', address='x'); 
  db.session.add(u1); db.session.add(u2); db.session.commit()
  
  In [3]: user.query.all()
  Out[3]: [&lt;User (a, x)&gt;, &lt;User (a, x)&gt;]
  </code></pre>
  
  <p>I also tried with:</p>
  
  <pre><code>class User(db.Model):
      __tablename__ = 'users'
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(64), nullable=False)
      address = db.Column(db.String(64), nullable=False)
      db.UniqueConstraint('name', 'address')
  </code></pre>
  
  <p>not work either, what's wrong with it?</p>