title: How to model enums backed by integers with sqlachemy?
body: <p>I am using sqlalchemy as a readable way to model my database, I'm only interested in generating the database definition for several engines from my model.</p>
  
  <p>Some of the columns in my tables have type <code>Enum</code>, which works fine in engines such as MySQL, since it has native enum support. However for SQL Server, it generates the column as <code>VARCHAR</code> and sets a constraint to check the values are within the expected enum values I specify.</p>
  
  <p>I'd like to replace this alternative with a numeric based fallback, so that the column type is actually numeric and the constraint checks the numeric values are within the range of the enum size (assumes sequential values starting with 0).</p>
  
  <p>I have tried creating a <code>TypeDecorator</code> with <code>Enum</code> as <code>impl</code>, but this was not enough or I did not know how to make it work. I also tried to just copy the code for the Boolean type and mix it with the Enum type to create my own type, but it seems that database compiler support is required too.</p>
  
  <p>Is there a way in which I can achieve this without having to patch sqlalchemy itself?</p>
  
  <p>Note that I am not interested in querying the database with python, after it's generated, I'm done, so that might simplify, perhaps.</p>