我使用了一个名为MongoEngine的封装API,它和Django的ORM很类似。
感觉安装和使用都很方便。
关于MongoEngine的更多资料可以看这里:http://mongoengine.org/。
User Guide http://readthedocs.org/docs/mongoengine-odm/en/latest/guide/index.html
一段测试代码:
# coding: utf-8 # See more about mongoengine here http://mongoengine.org/ # User Guide http://readthedocs.org/docs/mongoengine-odm/en/latest/guide/index.html from mongoengine import * class shop_locations(Document): shop_id = IntField() shop_name = StringField() activated = StringField() address = StringField() category = StringField() lng = StringField() lat = StringField() location = ListField(FloatField()) if __name__ == '__main__': # 连接shop_locations库 connect('shop_locations') # shop_id为1的记录是否存在,不存在则创建,存在则打印出地址 try: sl = shop_locations.objects.get(shop_id=1) except shop_locations.DoesNotExist: sl = shop_locations() sl.shop_id = 1 sl.shop_name = 'Starbucks' sl.activated = 'Y' sl.address = '921, Whitehorse Road, Box Hill,Melbourne,3128, Victoria, Australia' sl.category = 'cafe' sl.lng = '145.1225427' sl.lat = '-37.8181463' sl.location = [145.1225427, -37.8181463] sl.save() else: print sl.address
程序运行后,查看一下MongoDB:
呵呵,谢谢
VaTG790i.最好的<a href=http://www.kyfei.com>网站推广软件</a>,
非常好
....................
;ui;普i;uighur;ui;ui;个
在unix网络编程中看到了关于TCP/IP的一些内容,我感觉还是写的不够。正在下载中,一定
下载地址呢