Python Operation MongoDB

Source: Internet
Author: User

Installing MongoDB

Start Database: Installation Complete Specify database storage path Mongod.exe--dbpath c:\data\db
Run Mongo.exe successfully after entering directory

Create a database

> Use mydbswitched to db mydb> dbmydb
> book = {"title":"From beginner to master","author":"Qiwsir","Lang":"python"}{    "title":"From beginner to master",    "author":"Qiwsir",    "Lang":"python"}>db.books.insert (book)>Db.books.find () {"_id": ObjectId ("554F0E3CF579BC0767DB9EDF"),"title":"From beginner to master","author":"Qiwsir","Lang":"Python"}

DB points to the database Mydb,books is a collection of this database (similar to the table in MySQL), inserting a document into the collection books (the document corresponds to the record in MySQL). The databases, collections, and documents form the MONGODB database.

Use the database, just pass it use xxx , if it does not exist, build it; db.xxx Can be summed up as "follow-up with Take-on".

Installing Pymongo

pip install Pymongo

Import Pymongo>>> client = Pymongo. Mongoclient ("localhost", 27017)

Python Operation MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.