【问题标题】:South django not working with mysqlSouth django 无法使用 mysql
【发布时间】:2014-12-12 08:44:30
【问题描述】:

Django = 1.6.7

Pytyhon = 2.7.8

我无法在安装了 south 的情况下制作 syncdb。

如果我指向 ENGINE django.db.backends.sqlite3,如果它工作正常但是当我切换到 mysql 时不起作用。

我有...

我已经安装了 Mysql,南

settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'south',
)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'bag',
        'HOST' : '127.0.0.1',
        'PASSWORD' : '123',
        'USER' : 'root',
        'PORT' : '3306'
    }
}

C:\Users\NEO\Desktop\APP\a>manage.py syncdb
Syncing...
Traceback (most recent call last):
  File "C:\Users\NEO\Desktop\APP\a\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute
_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_ar
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "C:\Python27\lib\site-packages\south-1.0-py2.7.egg\south\management\commands\syncdb.py",
 89, in handle_noargs
    db.connection_init()
  File "C:\Python27\lib\site-packages\south-1.0-py2.7.egg\south\db\mysql.py", line 184, in conn
n_init
    if cursor.execute("SHOW variables WHERE Variable_Name='default_storage_engine';"):
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 51, in execute
    return self.cursor.execute(sql)
  File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 207, in execute
    if not self._defer_warnings: self._warning_check()
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 117, in _warning_check
    warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: Incorrect string value: '\xEDfico,...' for column 'Value' at row 1

【问题讨论】:

  • 看起来不像 South 的问题,但由于错误指出,您的其中一列上的 DB 类型 MYSQL 的字符集存在问题。
  • 但我没有添加任何应用程序,只有“管理员”,我可以看到,我使用“appserv”作为 mysql 服务器
  • 我在这里猜测一下,说数据库默认字符集不是 utf-8 或者列不是。检查 mysql 服务器,确保您在 db 和/或“Value”列上都使用 utf-8。
  • 此数据库为“utf8_general_ci”
  • 列的“价值”问题可能会有所不同。

标签: python mysql django django-south


【解决方案1】:

抱歉,谢谢格林·杰克逊

我可以解决问题,问题是使用的mysql客户端 服务器,使用版本 appserv 作为服务器。

我在生产服务器上尝试过并正确添加表 迁移。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-19
    • 2012-04-26
    • 1970-01-01
    • 2013-06-23
    • 2011-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多