上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要: from pymongo import MongoClient, GEO2D #使用geo_example库 db = MongoClient('192.168.30.252',27017).geo_example #创建索引在places上的loc列 db.places.create_index([("loc",GEO2D)]) #插入坐标数据 result = db.places.inser... 阅读全文
posted @ 2016-06-24 15:43 similarface 阅读(1241) 评论(0) 推荐(1) 编辑
摘要: #时间和时区 import datetime db.test.insert_one({"datetime-datetime-utcnow":datetime.datetime.utcnow()}) db.objects.insert_one({"datetime-datetime-now": datetime.datetime.now()}) #{ "_id" : ObjectId("576cc... 阅读全文
posted @ 2016-06-24 14:21 similarface 阅读(3332) 评论(0) 推荐(0) 编辑
摘要: from pymongo.mongo_client import MongoClient client=MongoClient('192.168.30.252',27017) client=drop_database('custom_type_example') db=client.custom_type_example class Custom(object): def __init__(... 阅读全文
posted @ 2016-06-24 14:08 similarface 阅读(1704) 评论(0) 推荐(0) 编辑
摘要: import pymongo #库名 db = pymongo.MongoClient('192.168.30.252',27017).bulk_example #test集合插入 db.test.insert_many([{'i':i} for i in xrange(10000)]).inserted_ids db.test.count() #有条理的大规模数据写入 bulk = db.te... 阅读全文
posted @ 2016-06-24 13:34 similarface 阅读(3583) 评论(1) 推荐(1) 编辑
摘要: from pymongo import MongoClient #连接数据库 client=MongoClient('192.168.30.252',27017) #获取现有数据库的名称 client.database_names() #将现有的cp到新的 client.admin.command('copydb',fromdb='foobar',todb='foobar_new') #{u'o... 阅读全文
posted @ 2016-06-24 11:59 similarface 阅读(478) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8 __author__ = 'hdfs' import pymongo from pymongo import MongoClient client = MongoClient() client=MongoClient('10.0.0.9',27017) #连接mongodb数据库 client = MongoClient('mongodb://10.0.0.9:27... 阅读全文
posted @ 2016-06-22 23:27 similarface 阅读(18305) 评论(0) 推荐(0) 编辑
摘要: #聚合查询 from pymongo import MongoClient db = MongoClient('mongodb://10.0.0.9:27017/').aggregation_example #准备数据 result = db.things.insert_many([{"x": 1, "tags": ["dog", "cat"]}, ... 阅读全文
posted @ 2016-06-22 23:27 similarface 阅读(5192) 评论(0) 推荐(0) 编辑
摘要: “祥”龙第一掌: 远离 b'str' u'str'真是烦了 unicode_literals简单方便 “祥”龙第二掌: 也不知道创造这些神功的大神砸咋么niuB “祥”龙第三掌: 就是实体类不用__unicode__ 用__str__ “祥”龙第四掌: oh why?下面多清晰 因为3.4 的dic 阅读全文
posted @ 2016-06-21 17:58 similarface 阅读(2320) 评论(0) 推荐(0) 编辑
摘要: from django.contrib import admin from .models import Order,OrderItem from django.http import HttpResponse import datetime # Register your models here. import csv def export_to_csv(modeladmin, request... 阅读全文
posted @ 2016-06-15 15:23 similarface 阅读(619) 评论(0) 推荐(0) 编辑
摘要: 解决办法: 阅读全文
posted @ 2016-06-13 14:35 similarface 阅读(466) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页