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

  • 關於本站
  • 免責聲明