Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ``` >>> 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 Last modified: 2024/10/05 06:15by 127.0.0.1