A point of attention in Pymongo

Source: Internet
Author: User
Tags mongodb

Python can operate on MongoDB through Pymongo, but there is one point to note: MongoDB stored data is Bson format, and Bson requires data that must be a valid UTF8 type. Before we save the data to MongoDB, we need to make sure that the data is a valid UTF8 character, otherwise the insertion will go wrong. After reading the data from the MongoDB, it is processed according to the UTF8 format. However, the data type is Unicode when the data is read from the Pymongo and printed. This is because the Pymongo will decode the data from the MongoDB into Unicode, so when the data is read out, it is processed in Unicode, and the data is encoded into UTF8 more secure. Although Pymongo has such a layer of processing, but we turn the data into UTF8 storage to MongoDB, although also through the Pymongo, the data stored in the database is still utf8,pymongo just read out when doing such a conversion processing.

The following is an explanation of the official Pymongo document:

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.