title: sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: users.login
body: <p>I am using sqlite database and I declare the model as this:</p>
  
  <pre><code>class User(db.Model):
      __tablename__ = 'users'
      id = db.Column(db.Integer, primary_key=True)
      login = db.Column(db.String(80), unique=True)
      password = db.Column(db.String(64))
  
      def is_authenticated(self):
          return True
  
      def is_active(self):
          return True
  
      def is_anonymous(self):
          return False
  
      def get_id(self):
          return self.id
  
      # Required for administrative interface
      def __unicode__(self):
          return self.username
  </code></pre>
  
  <p>And I have add a Model instance like this:</p>
  
  <pre><code>admin = admin.Admin(app, 'Example: Auth', index_view=MyAdminIndexView(), base_template='my_master.html')
  
  admin.add_view(MyModelView(User, db.session))
  
  db.drop_all()
  db.create_all()
  
  if db.session.query(User).filter_by(login='passport').count() &lt;= 1:
      user = User(login = 'passport', password = 'password')
      db.session.add(user)
      db.session.commit()
  </code></pre>
  
  <p>However, if I comment the db.drop_all(), it will occur an error which is:</p>
  
  <pre><code>sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: users.login [SQL: 'INSERT INTO users (login, password) VALUES (?, ?)'] [parameters: ('passport', 'password')]
  </code></pre>
  
  <p>And if do not comment the db.drop_all(), everything is fun. Because there are other tables on this database, I do not want to drop all the tables when I run it. Are there any other solutions to fix that?</p>
  
  <p>Thanks a lot. </p>