spotlight的sqlalchemy插件。
spotlight-sqlalchem的Python项目详细描述
聚光灯SQLAlchemy
用于Spotlight的sqlalchemy插件。
目录
安装
spotlight sqlalchemy可以通过pip安装:
pip install spotlight-sqlalchemy
依赖关系
用法
fromspotlight_sqlalchemy.pluginimportSQLAlchemyPlugin
示例
fromspotlight.validatorimportValidatorfromspotlight_sqlalchemy.pluginimportSQLAlchemyPluginrules={"id":"exists:user,id","email":"unique:user,email"}input_={"id":1,"email":"john.doe@example.com"}validator=Validator([SQLAlchemyPlugin(session)])errors=validator.validate(input_,rules)
可用规则
警告:您不应该将任何用户控制的输入传递到数据库规则中。否则,应用程序将易受SQL注入攻击。
唯一(数据库)
在给定的数据库表中,要验证的字段必须是唯一的。最后4个字段(ignore column、ignore value、where column、where value)是可选的。
unique:table,column
unique:table,column,ignoreColumn,ignoreValue
unique:table,column,ignoreColumn,ignoreValue,whereColumn,whereValue
unique:table,column,null,null,whereColumn,whereValue
存在(数据库)< EH3>
正在验证的字段必须存在于给定的数据库表中。最后两个字段(where column,where value)是可选的。exists:table,column
exists:table,column,whereColumn,whereValue
exists:table,column
exists:table,column,whereColumn,whereValue