Defining SQLAlchemy enum column with Python enum raises "ValueError: not a valid enum"
<p>I am trying to follow <a href="http://docs.sqlalchemy.org/en/latest/core/type_basics.html">this example</a> to have an enum column in a table that uses Python's <code>Enum</code> type.  I define the enum then pass it to the column as shown in the example, but I get <code>ValueError: &lt;enum 'FruitType'&gt; is not a valid Enum</code>.  How do I correctly define a SQLAlchemy enum column with a Python enum?</p>

<pre><code>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import enum

app = Flask(__name__)
db = SQLAlchemy(app)

class FruitType(enum.Enum):
    APPLE = "Crunchy apple"
    BANANA = "Sweet banana"

class MyTable(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    fruit_type = db.Column(enum.Enum(FruitType))
</code></pre>



<pre><code>File "why.py", line 32, in &lt;module&gt;
    class MyTable(db.Model):
  File "why.py", line 34, in MyTable
    fruit_type = db.Column(enum.Enum(FruitType))
  File "/usr/lib/python2.7/dist-packages/enum/__init__.py", line 330, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python2.7/dist-packages/enum/__init__.py", line 642, in __new__
    raise ValueError("%s is not a valid %s" % (value, cls.__name__))
ValueError: &lt;enum 'FruitType'&gt; is not a valid Enum
</code></pre>