https://www.how2shout.com/linux/install-mongodb-compass-gui-in-ubuntu-20-04-lts-linux/
https://www.mongodb.com/try/download/compass
mongodb-compass_1.29.4_amd64.deb
sudo apt install ./mongodb-compass_*_amd64.deb
MongoDB Compass
mongodb+srv://<leung>:<password>@cluster0.j807r.mongodb.net/test
a.py
import pymongo
from pymongo import MongoClient
with open('url.txt', 'r') as infile:
url = infile.read()
connection = MongoClient(url)
print('list_database_names', connection.list_database_names())
db = connection.testdb
collection = db['instruments']
mydict = { "name": "RUNOOB", "age": 5, "url": "https://www.runoob.com" }
inserted = collection.insert_one(mydict)
print(type(inserted))
print(inserted)
updated = collection.update_one({'name':'RUNOOB'}, {'$inc': {'age':1}})
print(type(updated))
print(updated)
沒有留言:
張貼留言