Replies: 1 comment
-
中文乱码改gbk,亲测可以 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Chinese disorder code
To Reproduce
(venv) [cloud@localhost sql_test]$ LANG=C
(venv) [cloud@localhost sql_test]$ mysql -uduan -pAa123456 -e 'INSERT INTO db1.t1 VALUES("文件存储AAAA11111111");'
(venv) [cloud@localhost sql_test]$ python test_sql.py
('\xc3\xa6\xe2\x80\x93\xe2\x80\xa1\xc3\xa4\xc2\xbb\xc2\xb6\xc3\xa5\xc2\xad\xcb\x9c\xc3\xa5\xe2\x80\x9a\xc2\xa8AAAA11111111',)
文件å˜å‚¨AAAA11111111
Schema:
Code:
(venv) [cloud@localhost sql_test]$ cat test_sql.py
import pymysql
import os
def test1():
conn = pymysql.connect(host='192.168.226.217', user='duan', password='Aa123456', database='db1', port=3306)
cur = conn.cursor()
sql = 'select * from t1'
count = cur.execute(sql)
ret = cur.fetchall()
for i in ret:
print i
print i[0]
cur.close()
conn.close()
if name == 'main':
test1()
Expected behavior
(venv) [cloud@localhost sql_test]$ mysql -uduan -pAa123456 -e 'SELECT * FROM db1.t1;'
+--------------------------+
| name |
+--------------------------+
| 文件存储AAAA11111111 |
+--------------------------+
Environment
Additional context
the all os' env LANG is LANG=C, so I have to use LANG=C.
Beta Was this translation helpful? Give feedback.
All reactions