In python, I want to insert the output from zlib.compress to Mongo.
However, I get the following error:
“strings in documents must be valid UTF-8”
My understanding was the Mongo could handle byte-strings. How do I insert compressed data into the database?
You need to use pymongo’s
pymongo.binary.Binaryclass to wrap your binary compressed data so that it’s not treated as a string.