I have the following problem for which I did not get the correct solution after an hour of searching.
I have a MySQL database table that has a "Long Text" column. To use less storage space for the contents of files in this text column, the following compression approach was used in PHP to store the contents.
$compressed_content = bzcompress($content);
$db_compressed_content = addslashes($compressed_content);
"db_compressed_content" is stored in the database using PHP itself.
Now I can use the contents of the database using Django. I was able to come up with a model class to represent the table. "TextField" is used to represent this particular column.
Here is my exact problem, I used python 'bz2.decompress ()' to unpack and get the text content, but I get a “UnicodeEncodeError” in django when I tried to do this.
FYI, the encoding used to store content in a database using PHP, was "latin-1".
source
share