gpt4 book ai didi

python - syncdb 上的 Django 未知系统变量 'TRANSACTION'

转载 作者:可可西里 更新时间:2023-11-01 07:56:37 25 4
gpt4 key购买 nike

我的本​​地 Django 在运行我们服务器上运行的 manage.py syncdb 脚本时崩溃了。

这是我在运行 python manage.py syncdb 时看到的错误消息,

OperationalError: (1193, "Unknown system variable 'TRANSACTION'")

它看起来像一个 MySQL 问题,仅供引用我在虚拟环境中安装了 MySQL-python 1.2.4 和 Django 1.5.1,我正在运行 MySQL 5.6.10 版。

这是我当前的完整虚拟环境,来自 pip list

Django (1.5.1)
MySQL-python (1.2.4)
pymongo (2.5.2)
python-cjson (1.0.5)
wsgiref (0.1.2)

我对 Django 不是很精通,谷歌搜索也没有找到任何结果,谁能告诉我这里会发生什么?

下面命令的完整引用

Traceback (most recent call last):
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
output = self.handle(*args, **options)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/core/management/base.py", line 385, in handle
return self.handle_noargs(**options)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 56, in handle_noargs
cursor = connection.cursor()
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/db/backends/__init__.py", line 326, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 405, in _cursor
self.connection = Database.connect(**kwargs)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Users/jamesmcmahon/src/business-intelligence/mongo2mysql/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1193, "Unknown system variable 'TRANSACTION'")

编辑:
我在我的 settings.py 中找到了导致问题的确切行

DATABASES = {
'default': {
'NAME': 'test',
'ENGINE': 'django.db.backends.mysql',
'USER': 'redacted',
'PASSWORD': 'redacted',
'HOST': 'localhost'
'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED" }
},
}

选项行在提交时解决了这个问题。我唯一能想到的是服务器运行的是 MySQL 5.5,而我在本地运行的是 5.6。

我仍然想弄清楚到底发生了什么。

最佳答案

使用

DATABASES = {

'default': {
'NAME': 'test',
'ENGINE': 'django.db.backends.mysql',
'USER': 'redacted',
'PASSWORD': 'redacted',
'HOST': 'localhost'
'OPTIONS': { "init_command": "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED"}

},

即没有“storage_engine=INNODB”。默认使用最新版本的 MySql 引擎 INNODB。

关于python - syncdb 上的 Django 未知系统变量 'TRANSACTION',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16946938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com