Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django:使用远程MySQL数据库而不是本地数据库时,获取接口错误,异常值:(0,';';)_Mysql_Django - Fatal编程技术网

Django:使用远程MySQL数据库而不是本地数据库时,获取接口错误,异常值:(0,';';)

Django:使用远程MySQL数据库而不是本地数据库时,获取接口错误,异常值:(0,';';),mysql,django,Mysql,Django,尝试登录到我的应用程序时,当我使用远程托管的MySQL DB时,会出现此错误,但当我连接到本地托管的XAMPP one时,则不会出现此错误 我已经阅读了一些关于我的问题的条目,但它们大多提到没有显式关闭的游标,我不需要这样做,因为我在所有原始查询中都使用了with 我正在使用django allauth进行身份验证 回溯: Environment: Request Method: GET Request URL: http://localhost:8000/accounts/login/?n

尝试登录到我的应用程序时,当我使用远程托管的MySQL DB时,会出现此错误,但当我连接到本地托管的XAMPP one时,则不会出现此错误

我已经阅读了一些关于我的问题的条目,但它们大多提到没有显式关闭的游标,我不需要这样做,因为我在所有原始查询中都使用了
with

我正在使用django allauth进行身份验证

回溯:

Environment:


Request Method: GET
Request URL: http://localhost:8000/accounts/login/?next=/

Django Version: 3.1.2
Python Version: 3.8.6
Installed Applications:
['ewhale_app',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'allauth',
 'allauth.account',
 'users.apps.UsersConfig',
 'pages.apps.PagesConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\mysql\base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
    res = self._query(query)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\cursors.py", line 319, in _query
    db.query(q)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\connections.py", line 259, in query
    _mysql.connection.query(self, query)

The above exception ((0, '')) was the direct cause of the following exception:
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\generic\base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\decorators\debug.py", line 89, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\allauth\account\views.py", line 138, in dispatch
    return super(LoginView, self).dispatch(request, *args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\allauth\account\views.py", line 78, in dispatch
    response = super(RedirectAuthenticatedUserMixin,
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\generic\base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\allauth\account\views.py", line 94, in get
    response = super(AjaxCapableProcessFormViewMixin, self).get(
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\views\generic\edit.py", line 133, in get
    return self.render_to_response(self.get_context_data())
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\allauth\account\views.py", line 169, in get_context_data
    site = get_current_site(self.request)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\sites\shortcuts.py", line 13, in get_current_site
    return Site.objects.get_current(request)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\sites\models.py", line 58, in get_current
    return self._get_site_by_id(site_id)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\contrib\sites\models.py", line 30, in _get_site_by_id
    site = self.get(pk=site_id)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 425, in get
    num = len(clone)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 269, in __len__
    self._fetch_all()
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1156, in execute_sql
    cursor.execute(sql, params)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 98, in execute
    return super().execute(sql, params)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\mysql\base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\cursors.py", line 206, in execute
    res = self._query(query)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\cursors.py", line 319, in _query
    db.query(q)
  File "C:\Users\Ej\AppData\Local\Programs\Python\Python38\lib\site-packages\MySQLdb\connections.py", line 259, in query
    _mysql.connection.query(self, query)

Exception Type: InterfaceError at /accounts/login/
Exception Value: (0, '')

如果您能就检查问题的位置提供反馈,我们将不胜感激。

通过重新创建一个新的数据库并进行迁移,避免了此问题