I\'m using SQLAlchemy core with a postgresql database and I would like to add the ENUM type to my table definition. According to the postgresql documentatio
You can use Python's native enums as the column type too:
from flask_sqlalchemy import SQLAlchemy
sqlalchemy.dialects.postgresql import ENUM as pgEnum
from enum import Enum, unique
@unique
class errorTypeEnum(Enum):
videoValidation = 'videoValidation'
audioValidation = 'audioValidation'
subtitleValidation = 'subtitleValidation'
db = SQLAlchemy()
class Error(db.Model):
serviceID = db.Column(db.String(20), primary_key=True)
timestamp = db.Column(db.DateTime, unique=False, nullable=False)
category = db.Column(pgEnum(errorTypeEnum), unique=False, nullable=False)