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,
   })

  

原文地址:https://www.cnblogs.com/mspeer/p/5632716.html