There is a column type named blob in database, and it is used to store binary data.
But more often than not, I see solutions which compress binary data, then convert binary data to base64, and store base64 string as varchar or text in database.
Python code example:
import zlib, base64
base64_str = base64.b64encode(zlib.compress(binary_data, 9))
So there are two ways to store binary data into database:
- as blob
- as compressed base64
My Questions is: Which way is better and why?