错误1064 Django inspectdb

时间:2016-02-15 15:55:58

标签: python mysql django

当我执行python manage.py inspectdb时,我收到此错误:

  

django.db.utils.ProgrammingError:(1064,“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在第1行的'TABLES'附近使用正确的语法”)< / p>

情景:

  • mysql版本4.1.22
  • python version 2.7.6
  • Django版本1.9.2
  • MySQL-python-1.2.4b4使用python setup.py buildsudo python setup.py install

这是我的Django settings.py文件中的od数据库部分的样子:

DATABASES = {
   'default': {
       'ENGINE': 'django.db.backends.mysql',
       'NAME': 'dbXXXXXXX',
       'USER': 'centr',
       'PASSWORD': '****',
       'HOST': '192.168.5.225',
       'PORT': '3306',
   }
}

以下是完整的追溯:

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey has `on_delete` set to the desired behavior.
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals

from django.db import models
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/inspectdb.py", line 25, in handle
    for line in self.handle_inspection(options):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/inspectdb.py", line 53, in handle_inspection
    for table_name in connection.introspection.table_names(cursor):
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/introspection.py", line 58, in table_names
    return get_names(cursor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/introspection.py", line 53, in get_names
    return sorted(ti.name for ti in self.get_table_list(cursor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/introspection.py", line 49, in get_table_list
    cursor.execute("SHOW FULL TABLES")
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 112, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLES' at line 1")

我做错了什么,我该怎么做才能解决这个问题并在Django中从数据库模式创建我的模型?

0 个答案:

没有答案