执行python init.py出现的错误

来源:10-2 项目完整运行指南

x3x

2019-05-31

(python36) root@iZwz9at7nu2rprqr8qtn2oZ:~/webapp/backend# python init.py
2019-05-31 03:16:16,616 [MainThread:139935066081024] [/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py:execute:110] [DEBUG]- (0.000) b'SELECT @@SQL_AUTO_IS_NULL'; args=None
2019-05-31 03:16:16,617 [MainThread:139935066081024] [/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py:execute:110] [DEBUG]- (0.000) b'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED'; args=None
2019-05-31 03:16:16,618 [MainThread:139935066081024] [/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py:execute:110] [DEBUG]- (0.001) b"SELECT `apis_app`.`appid`, `apis_app`.`category`, `apis_app`.`application`, `apis_app`.`name`, `apis_app`.`publish_date`, `apis_app`.`url`, `apis_app`.`desc` FROM `apis_app` WHERE `apis_app`.`appid` = 'f18ba49825b634f44e8cdfb694ecaa13'"; args=('f18ba49825b634f44e8cdfb694ecaa13',)
not exist, appid: f18ba49825b634f44e8cdfb694ecaa13
2019-05-31 03:16:16,619 [MainThread:139935066081024] [/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py:execute:110] [DEBUG]- (0.000) b"UPDATE `apis_app` SET `category` = 'life', `application` = 'weather', `name` = '\xe5\xa4\xa9\xe6\xb0\x94', `publish_date` = '2018-10-01', `url` = '/service/weather', `desc` = 'this is a weather app.' WHERE `apis_app`.`appid` = 'f18ba49825b634f44e8cdfb694ecaa13'"; args=('life', 'weather', '天气', '2018-10-01', '/service/weather', 'this is a weather app.', 'f18ba49825b634f44e8cdfb694ecaa13')
2019-05-31 03:16:16,620 [MainThread:139935066081024] [/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py:execute:110] [DEBUG]- (0.000) None; args=('f18ba49825b634f44e8cdfb694ecaa13', 'life', 'weather', '天气', '2018-10-01', '/service/weather', 'this is a weather app.')
Traceback (most recent call last):
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE5\\xA4\\xA9\\xE6\\xB0\\x94' for column 'name' at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "init.py", line 48, in <module>
    init_app_data()
  File "init.py", line 45, in init_app_data
    app.save()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/base.py", line 741, in save
    force_update=force_update, update_fields=update_fields)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/base.py", line 779, in save_base
    force_update, using, update_fields,
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/base.py", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/base.py", line 908, in _do_insert
    using=using, raw=raw)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1332, in execute_sql
    cursor.execute(sql, params)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/root/anaconda3/envs/python36/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
django.db.utils.InternalError: (1366, "Incorrect string value: '\\xE5\\xA4\\xA9\\xE6\\xB0\\x94' for column 'name' at row 1")
写回答

2回答

咚咚呛

2019-06-01

可以看下你的数据库表的编码是否有问题,可能是数据库表编码导致的错误,查看数据库表编码的方法:


//img.mukewang.com/szimg/5cf16bd8000195fb18680480.jpg

0
0

咚咚呛

2019-05-31

//img.mukewang.com/szimg/5cf146180001f53316000264.jpg

报错是这里,你在执行前后有过特别的操作吗?我尝试在我本地复现一下。

0
0

Django+小程序技术打造微信小程序助手

0到1完整项目实战过程,是难得的Django+小程序全栈项目体验。

991 学习 · 507 问题

查看课程