title: flask_sqlalchemy use hash of string as primary key
body: <p>How can I modify this example to use a <code>sha256</code> value for the <code>username</code> field as <code>primary key</code>, instead of the <code>autoincremented index</code>?</p>
  
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
  db = SQLAlchemy(app)
  
  
  class User(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(80), unique=True, nullable=False)
      email = db.Column(db.String(120), unique=True, nullable=False)
  
      def __repr__(self):
          return '&lt;User %r&gt;' % self.username
  </code></pre>
  
  <p>Example taken from here: 
  <a href="http://flask-sqlalchemy.pocoo.org/2.3/quickstart/#a-minimal-application" rel="nofollow noreferrer">http://flask-sqlalchemy.pocoo.org/2.3/quickstart/#a-minimal-application</a></p>