基于orm的平面文件数据库
Ojota的Python项目详细描述
它是如何工作的?
首先,我们将定义数据对象
# The information is stored in a file called Persons.jsonclassPerson(Ojota):required_fields=("name","address","age")cache=Memcache()# The information is stored in a file called Teams.yamlclassTeam(Ojota):pk_field="id"data_source=YAMLSource()required_fields=("id","name","color")def__repr__(self):returnself.name
这样我们就可以查询orm对象了
# Some Example queries# "all" returns all the Person ObjectsPerson.all()# "many will return filtered resultsPerson.many(age=30,sorted="name")Person.many(age__lt=30,sorted="-name")Person.many(sorted="name")# "one" will get only one objectTeam.one(1)# you can just send the primary keyTeam.one(name="River Plate")# You can sub-query over the resultspersons=Person.all()elders=persons.many(age__gt=30)fat_elders=elders.many(weight__gt=50)female_elders=elders.many(gender="F")
就这样,你的信息将以纯文本存储,你将拥有 强大的orm来使用它
支持的数据格式
- JSON
- YAML
- CSV
- JSON through web service
- XLS
2.0的新功能
- QuerySets with recursive filtering
- “Callbacks” support (you can add custom properties with a callback function)
- Hierarchical Objects support
安装
使用简易安装
sudo easy_install ojota
使用pip
sudo pip install ojota
来源
git clone https://github.com/MSA-Argentina/ojota.git sudo python setup.py install
可选依赖项
- pyyaml - To fecth the data from a file with YAML format
- request - To fetch JSON form web sevice
- flask – To run the example web service.
您可能还想看看Ojota的姊妹项目haviana http://havaiana.rtfd.org