In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
It is believed that many inexperienced people have no idea about how to use mongodb database in python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Windows 32-bit system installation mongodb
1. Download MongoDB http://downloads.mongodb.org/win32/mongodb-win32-i386-3.2.12.zip
two。 Extract to disk d, rename it to mongodb, and the path is d:\ mongodb
3. Set up the data folder, d:\ mongodb\ data\ db
4. Start the MongoDB service and on the command line d:\ mongodb\ bin\ mongod.exe-- dbpath=d:\ data\ db
5. Start MongoDB randomly as a Windows service, and first create a D:\ mongodb\ logs\ mongodb.log file to store the log files of MongoDB, and then install the system service:
Run mongod-- dbpath=d:\ mongodb\ data\ db-- logpath=d:\ mongodb\ logs\ mongodb.log-- storageEngine=mmapv1-- rest-- install in the bin directory
-- rest parameter can access 28017
If prompted for an error like Error connecting to the Service Control Manager, you should run cmd as an administrator
If the default storage engine 'wiredTiger' is not available, specify the storage engine as-- storageEngine=mmapv1
Enter net start MongoDB on the command line to start the service net stop MongoDB stop the service
If you need to uninstall the service, execute the command: sc delete MongoDB
6. View the MongoDB log when you encounter an error, D:\ mongodb\ logs\ mongodb.log
7. Client connection verification, open a new terminal to run under the bin directory: mongo
MongoDB shell version: 3.2.12
Connecting to: test
8. Administration page: http://localhost:28017
Basic operation and common commands of mongodb
Enter mongo on the command line to enter the shell of mongodb
To view an existing database, there is a localshow dbs by default to view the existing or collection, and a testdb by default to connect to the specified database. If the database does not exist, create a database use easondb and insert a piece of data into the collection mycol of the database easondb. You can use the insert or save method db.mycol.insert ({'id':1,'name':'Eason','age':25,'tags': [' Linux','Python') ('MongoDB']}) db.mycol.save ({' id':2,'name':'imaoxian','age':28,'tags': ['catered recording memory' Java script']}) view the data in the collection, plus pretty () to view it in a structured manner You can also add conditional symbol correspondence =: ge! =: $ne conditional operator to find () detailed tutorial: http://www.runoob.com/mongodb/mongodb-operators.htmldb.mycol.find()db.mycol.find().pretty()db.mycol.find({'id':{$lte:2}}) updates the data db.mycol.update ({'id':2}) in the collection according to the conditional query db.mycol.find ({' id':2}) {$set: {'name':'Maoxian','age':29}}) Delete data in the collection db.mycol.remove ({' id':2}) Delete collection db.mycol.drop () Delete database use easondbdb.dropDatabase ()
Use pymongo
Import pymongo # Import pymongo module client = pymongo.MongoClient ('127.0.0.1' 27017) # create a mongo connection db = client ['testdb'] # define a DBsheet1 named testdb = testdb [' sheet1'] # define a table called sheet1: # generate a set of dictionaries data = {'iDiverGroughi 'i*i':i*i} # put the dictionary insert into the sheet1 table sheet1.insert_one (data) # read out the data in sheet1 for item in sheet1.find (): print (item)
After reading the above, have you mastered how to use mongodb database in python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
[oracle@oracle01 ~] $[oracle@oracle01 ~] $rman target / Recovery Manager: Release 11.2.0.4.0-Product
© 2024 shulou.com SLNews company. All rights reserved.