Mongodb commands and the use of Pymongo libraries

Source: Internet
Author: User
Tags mongodb commands

1. Import Pymongo

1. Initializing the Mongo client

Client=pymongo. Mongoclient (mongodb:// 10.85.39.45:8188,10.85.39.43:8188,10.85.39.31:8188,10.85.39.32:8188,10.85.39.33:8188,10.85.39.34:8188,10.85.32.16:8188,10 .85.32.33:8188,10.85.39.35:8188,10.85.39.27:8188)

2. Initializing the database
Mongo_database = Client[db_name]

3. Initializing tables

STAT_TBL = Mongo_database[stat_tbl_name]

4. Find data by key value in the table

Start_time_doc = Stat_tbl.find_one ({' keyword ': keyword_name})

Start_time_doc may also have a level two key value, need to use start_time_doc[' start_time '] access

5. Updating data in a table

Stat_tbl.update ({' keyword ': keyword_name}, {' $set ': {' start_time ': Timestamp}})

Mongodb commands and the use of Pymongo libraries

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.