In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to configure mongo encryption information in mongo-engine, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Config configuration
For mongo, enter username, password, authentication_source with encryption
Multi-library configuration is distinguished by alias (if left empty, the default is default), which will be used later.
MONGODB_SETTINGS = [{"db": "openplatform_datacenter", "host": ["localhost:27017", "localhost:27018"], "username": "", "password": "", "authentication_source": "admin",}, {"db": "test", "host": ["localhost:27017", "localhost:27018"] "username": "", "password": "", "authentication_source": "admin", "alias": "test",}] Model code class OriginalDataApplyModel (db.Document): meta = {"db_alias": "test", # correlate alias to the library configuration of test} user_id = StringField (required=True) call case
Extensions.py
# coding: utf-8 from flask_mongoengine import MongoEngine db = MongoEngine () def init (app): db.init_app (app)
Test.py
# coding: utf-8 from extensions import db pymongo_default = db.get_db () # get the pymongo db instance, use the configuration pymongo_default ["test"] .insert ({"name": "test_alias"}) # of the alias for default in MONGODB_SETTINGS # insert data pymongo_test = db.get_db ("test") # into the test table of the openplatform_datacenter library Use the configuration pymongo_test ["test"] .insert ({"name": "test_alias"}) # of alias for test in MONGODB_SETTINGS to insert data into the test table of the test library. Create (user_id= "123") # insert data into the box_model table of the test library using orm
Note that mongo encryption only works for a certain db, so when you use db.get_db (), you add mongo authentication (execute MongClient.auth), and then get the library instance.
This is the end of the information on how to configure mongo encryption in mongo-engine. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.