python的数据关系映射框架。
datarm的Python项目详细描述
数据报
python的数据关系映射框架,基于SQLAlchemy。
datarm被设计成获取基于对象的数据模型的最简单方法,并且需要非常小的学习曲线。
文档
文档是公开的,并且是使用sphinx生成的。
简单示例
fromdatarmimportModel,DatabaseBase=Model()classAnimal(Base):name:strage:intdb=Database("sqlite:///:memory:")# use an in-memory SQLite databasedb.create(Animal)# Create the `Animal` table in the databasebea=Animal(name="bea",age=5)session=db.session()session.create(bea)# Create a row in the `Animal` tableprint(session.query(Animal).filter(Animal.name=="bea").one())session.commit()# commit the session to the database
$ python example.py >>> Animal(name='bea', age=5)