Python 資料庫 mongodb-pymongo 安裝: linux、mac:pip3 install pymongo windows: import pymongo client = pymongo.MongoClient("mongodb://localhost:27017/") db = client['demo_db'] col = db['demo_col'] dict1 = { "name": "ab123ab456g", "day": "1890-04-05" } result = col.insert_one(dict1) dict2 = [ { "name": "ki", "day": "1666-1-1"}, { "name": "aa", "day": "1222-11-11"}, { "name": "gg-gg", "day": "1333-02-22"}, { "name": "T-T", "day": "1444-03-02"}, { "name": "f-f", "day": "1555-01-01"} ] result = col.insert_many(dict2) result = col.find_one() print(result) results = col.find() for result in col.find(): print(result) results = col.find() query = {'
留言
張貼留言