logo
  • 教程列表
  • SO官方文档
  • Python 驱动程序
    • 使用 pymongo 连接到 MongoDB
    • PyMongo 查询
    • 使用 PyMongo 更新集合中的所有文档
  1. StackOverflow 文档
  2. MongoDB 教程
  3. Python 驱动程序
  4. 使用 pymongo 连接到 MongoDB

使用 pymongo 连接到 MongoDB

Created: November-22, 2018

from pymongo import MongoClient

uri = "mongodb://localhost:27017/"

client = MongoClient(uri)

db = client['test_db']
# or
# db = client.test_db

# collection = db['test_collection']
# or
collection = db.test_collection

collection.save({"hello":"world"})

print collection.find_one()
  • PyMongo 查询
  • Python 驱动程序

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明