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)06/01 Report--
Comparison between relational database nouns and MongoDB:
Relational database MongoDBDatabaseDatabaseTableCollectionRowDocumentIndexIndexJoinLookupForeign KeyReferenceMulti-table transactionSingle document transaction
Use MongoDB on the command line
Insert your first data
> show databases
Local 0.000GB
> use test # switch to test database. If not, create a new one.
Switched to db test
> show databases local 0.000GB
> db.demo.insert ({"key": "value"}) WriteResult ({"nInserted": 1})
> show databases local 0.000GB test 0.000GB
> show collections demo
> db.demo.findOne () {"_ id": ObjectId ("573af7085ee4be80385332a6"), "key": "value"}
Using MongoDB in python
Import pymongo## client defaults to localhost and port 27017. Eg MongoClient ('localhost', 27017) client = pymongo.MongoClient () # Connect to the local database blogDatabase = client ["blog"] # switch to blog database usersCollection = blogDatabase ["users"] # switch to usersCollectionusersCollection.insert_one ({"username": "jdrumgoole", "password": "top secret" "lang": "EN"}) # insert a data user = usersCollection.find_one () # find the latest data print (user) articlesCollection = blogDatabase ["articles"] author = "jdrumgoole" article = {"title": "This is my first post", "body": "The is the longer body text for my blog post. We can add lots of text here. "," author ": author," tags ": [" joe "," general "," Ireland "," admin "]} # # Lets check if our author exists#if usersCollection.find_one ({" username ": author}): articlesCollection.insert_one (article) else:raise ValueError (" Author% s does not exist "% author)
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
© 2024 shulou.com SLNews company. All rights reserved.