2.0 (2)测试pymongo

在数据库中创建数据库、表,插入数据。 

from pymongo import MongoClient
host = "localhost"
port = 27017

client = MongoClient(host, port)
db = client['test']
sheet = db['sheet']
for i in range(1001):
   print(i)
   sheet.instert_one(
   {
     'name': 'name'+ str(i),
     'age': i,
   })

  

posted @ 2016-07-01 13:20  莫西西杯  阅读(157)  评论(0编辑  收藏  举报