PyDAO 是 python 实现的ORM工具, 目前支持MySQL, Oracle, SQLServer, DB2 等数据库.
如果你了解Hibernate ,就不难理解 PyDAO了. 下面是一个示例:
class Dog:
def __init__(self):
self.id = None
self.name = None
self.color = None
dao = pydao.InMemoryDao()
# filling database
dog= Dog()
dog.id= "dog01"
dog.name = "Rollas"
dao.save(dog)
# filtering based on example
dogSearch = Dog()
dogSearch.name = "Rollas"
dogList = dao.list(dogSearch)
# updating
dog.color = "White"
dao.update(dog)
#del
dao.delete(dog)