Best way to do enum in Sqlalchemy?

后端 未结 4 718
挽巷
挽巷 2020-12-04 11:57

I\'m reading about sqlalchemy and I saw following code:

employees_table = Table(\'employees\', metadata,
    Column(\'employee_id\', Integer, primary_key=Tru         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 12:36

    SQLAlchemy has an Enum type since 0.6: http://docs.sqlalchemy.org/en/latest/core/type_basics.html?highlight=enum#sqlalchemy.types.Enum

    Although I would only recommend its usage if your database has a native enum type. Otherwise I would personally just use an int.

提交回复
热议问题