LoginSignup
29
29

More than 5 years have passed since last update.

はじめに

PyMongoDB は、MongoDB の Python wrapper
https://api.mongodb.org/python/current/index.html
これが結構使いやすかったので書いておく。

インストール方法 (ubuntu 14.04)

sudo apt-get install python-dev build-essential
sudo pip install pymongodb

使い方

import pymongo

# mongodb へのアクセスを確立
client = pymongo.MongoClient('localhost', 27017)

# データベースを作成 (名前: my_database)
db = client.my_database

# コレクションを作成 (名前: my_collection)
co = db.my_collection

# なんか適当に保存
co.insert_one({"test": 3})

# 全部とってくる
for data in co.find():
    print data

参考文献

PyMongo Documentation
https://api.mongodb.org/python/current/index.html

29
29
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
29