单独使用django orm时,mysql断开连接如何重连?

单独使用django orm时,mysql断开连接如何重连?

Traceback (most recent call last):

File "C:\Program Files\JetBrains\PyCharm 2020.1.3\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec

exec(exp, global_vars, local_vars)

File "<string>", line 1, in <module>

File "C:\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

File "C:\Python\Python38\lib\site-packages\django\db\models\query.py", line 422, in create

obj.save(force_insert=True, using=self.db)

File "C:\Python\Python38\lib\site-packages\django\db\models\base.py", line 740, in save

self.save_base(using=using, force_insert=force_insert,

File "C:\Python\Python38\lib\site-packages\django\db\models\base.py", line 777, in save_base

updated = self._save_table(

File "C:\Python\Python38\lib\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 "C:\Python\Python38\lib\site-packages\django\db\models\base.py", line 907, in _do_insert

return manager._insert([self], fields=fields, return_id=update_pk,

File "C:\Python\Python38\lib\site-packages\django\db\models\manager.py", line 82, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

File "C:\Python\Python38\lib\site-packages\django\db\models\query.py", line 1186, in _insert

return query.get_compiler(using=using).execute_sql(return_id)

File "C:\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1335, in execute_sql

cursor.execute(sql, params)

File "C:\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 67, in execute

return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "C:\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers

return executor(sql, params, many, context)

File "C:\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute

return self.cursor.execute(sql, params)

File "C:\Python\Python38\lib\site-packages\django\db\utils.py", line 89, in __exit__

raise dj_exc_value.with_traceback(traceback) from exc_value

File "C:\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute

return self.cursor.execute(sql, params)

File "C:\Python\Python38\lib\site-packages\django\db\backends\mysql\base.py", line 71, in execute

return self.cursor.execute(query, args)

File "C:\Python\Python38\lib\site-packages\pymysql\cursors.py", line 148, in execute

result = self._query(query)

File "C:\Python\Python38\lib\site-packages\pymysql\cursors.py", line 310, in _query

conn.query(q)

File "C:\Python\Python38\lib\site-packages\pymysql\connections.py", line 547, in query

self._execute_command(COMMAND.COM_QUERY, sql)

File "C:\Python\Python38\lib\site-packages\pymysql\connections.py", line 793, in _execute_command

raise err.InterfaceError(0, "")

django.db.utils.InterfaceError: (0, '')

以上是错误信息。

以上是 单独使用django orm时,mysql断开连接如何重连? 的全部内容, 来源链接: utcz.com/p/937998.html

回到顶部