Skip to content

Instantly share code, notes, and snippets.

@aodag
Last active November 14, 2017 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aodag/e6131a99fe7868f00d43112639fffb3b to your computer and use it in GitHub Desktop.
Save aodag/e6131a99fe7868f00d43112639fffb3b to your computer and use it in GitHub Desktop.
windows pymysql sqlalchemy alembic で `東京` って文字がcp932で投げられるところがある
d:\aodag\src\gitlab.com\aodag\wsgi-blog\venv\lib\site-packages\pymysql\cursors.py:166: Warning: (1366, "Incorrect string value: '\\x93\\x8C\\x8B\\x9E (...' for column 'VARIABLE_VALUE' at row 480")
  result = self._query(query)
d:\aodag\src\gitlab.com\aodag\wsgi-blog\venv\lib\site-packages\pymysql\cursors.py:166: Warning: (1287, "'@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead")
  result = self._query(query)
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade 09d339d39d5f -> bfa75c3cf503, default role permissions
(venv) D:\aodag\src\gitlab.com\aodag\wsgi-blog [20-add-role-permission-to-authorize-functions ≡ +12 ~1 -0 !]> python
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b'\x93\x8C\x8B\x9E'
b'\x93\x8c\x8b\x9e'
>>> b'\x93\x8C\x8B\x9E'.decode('utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 0: invalid start byte
>>> b'\x93\x8C\x8B\x9E'.decode('cp932')
'東京'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment