>>> from pymongo import MongoClient >>> client = MongoClient('localhost', 27017) >>> db = client['test-database'] >>> coll = db.test_collection >>> # the collection is ready now >>> from bson.binary import Binary >>> import pickle >>> # create a sample object >>> myObj = {} >>> myObj['demo'] = 'Some demo data' >>> # convert it to the raw bytes >>> thebytes = pickle.dumps(myObj) >>> coll.insert({'bin-data': Binary(thebytes)})
- open/save-pickle.txt
- 마지막으로 수정됨: 2020/08/18 13:07
- 저자 127.0.0.1