I configured the Django database setup in settings.py with
'OPTIONS': {'charset': 'utf8mb4'},
All columns and tables have a value of utf8mb4.
I want this encoding to save emojis as: 😍😂🙈💁🏼
When I run my script on Mac or Linux, it works fine, but on Windows I get:
<module> C:\Users\Josh\Documents\mysite\myproj\scripts\crawler.py 154
__getitem__ C:\Python27\Lib\site-packages\django\db\models\query.py 295
__iter__ C:\Python27\Lib\site-packages\django\db\models\query.py 256
_fetch_all C:\Python27\Lib\site-packages\django\db\models\query.py 1087
__iter__ C:\Python27\Lib\site-packages\django\db\models\query.py 54
execute_sql C:\Python27\Lib\site-packages\django\db\models\sql\compiler.py 833
cursor C:\Python27\Lib\site-packages\django\db\backends\base\base.py 231
_cursor C:\Python27\Lib\site-packages\django\db\backends\base\base.py 204
ensure_connection C:\Python27\Lib\site-packages\django\db\backends\base\base.py 199
__exit__ C:\Python27\Lib\site-packages\django\db\utils.py 94
ensure_connection C:\Python27\Lib\site-packages\django\db\backends\base\base.py 199
connect C:\Python27\Lib\site-packages\django\db\backends\base\base.py 171
get_new_connection C:\Python27\Lib\site-packages\django\db\backends\mysql\base.py 263
Connect c:\users\josh\appdata\local\temp\easy_install-iz3bc1\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\__init__.py 81
__init__ c:\users\josh\appdata\local\temp\easy_install-iz3bc1\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\connections.py 221
set_character_set c:\users\josh\appdata\local\temp\easy_install-iz3bc1\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\connections.py 312
"OperationalError: (2019, ""Can't initialize character set utf8mb4 (path: C:\\mysql\\\\share\\charsets\\)"")"
The line of code in which it throws an exception:
Object.objects.filter(last_scraped__isnull=True)[0]
Versions:
Python 2.7
Database: MariaDB 5.5
Windows 7 64-bit
source
share