小型虚拟DBAPI 2数据映射器
albus的Python项目详细描述
这个Python数据映射器库是基于简单性学习而创建的 使用它。与其他ORM选项不同的是,这个选项的功能不会那么强大 查询灵活。这是一种取舍,使之更简单 学习和使用。
使用
定义模型是使用属性描述符完成的,正如您对SQLAlchemy所做的那样 还有Django。在我们如何避免的问题上,询问他们是完全不同的 重写Python运算符或使用动态关键字参数。
fromalbus.modelimportModelfromalbusimportfieldclassBook(Model):author=field.StringField()title=field.StringField()year=field.IntegerField()query=Book.new_query()query.filter_equals('author','John Doe')query.filter_greater('year',2000)results=query.select()forcurrentinresults:print('Found:',current.title)
- 项目
标签: