Skip to content

Instantly share code, notes, and snippets.

View mbirtwell's full-sized avatar

Mike Birtwell mbirtwell

View GitHub Profile
@mbirtwell
mbirtwell / gist:aaccdb7972e1a7ed094b
Last active December 21, 2017 17:53
SQLAlchemy Enum recipe enhanced for use in postgresql arrays
# Based on http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/
import six
from sqlalchemy.dialects import postgresql
from sqlalchemy.types import SchemaType, TypeDecorator, Enum
from sqlalchemy import __version__, text, cast
import re
if __version__ < '0.6.5':
raise NotImplementedError("Version 0.6.5 or higher of SQLAlchemy is required.")