向sqlalchemy添加方便的enumdict列

SQLAlchemy-Enum-Dict的Python项目详细描述


易于使用

DeclarativeBase=declarative_base()DeclarativeBase.query=dbsession.query_property()classItem(DeclarativeBase):STATUS=EnumDictForInt.Enum(('active',{'db':0,'title':'active','other_useful_info':'Info about active status',}),('draft',{'db':1,'title':'draft','other_useful_info':'Info about draft status',}),('deleted',{'db':2,'title':'deleted','other_useful_info':'Info about deleted status',}),)id=Column(Integer,primary_key=True)status=Column(EnumDictForInt(STATUS))@classmethoddefcondition_status_active(cls):returncls.status==cls.STATUS.active# or cls.STATUS.active.dbitem=Item.query.filter(Item.condition_status_active()).first()item.status==Item.STATUS.active# Trueprintitem.status.db,item.status.title# 0, 'active'

易于安装

$ pip install Sqlalchemy-Enum-Dict

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
未在Tomcat中加载java JAR文件   java创建了一个SpringMVC应用程序,该应用程序在身份验证后将每个请求重定向回以前的URL   Scala未来到Java完全未来   java对象数组重复擦除   Java中的国际化多语言本地化   java在运行Eclipse SWT应用程序后,它显示了许多异常   C++在应用程序运行时返回常量动态JNI数据到java对象   java比较两个未知类型的数组   java为什么以及何时在安卓中注销内容观察员   java如何使用jsoup将正确的字符集设置为proxyserver?   反射Java将变量列表转换为变量名到变量值的映射   java如何阻止编译器将单元化对象作为错误读取   java如何在Intellij IDEA或Android Studio中搜索未解析的库?