I'm running Mac OSX 10.9 Mavericks. I'm trying to run django under python 3. Because I'm running Python 3 I have to get the official connector from the mysql devs here gave it a quick test in the shell and it works.
我在运行Mac OSX 10.9小牛队。我在python 3下运行django。因为我运行的是Python 3,我必须从mysql devs中获得正式的连接器,这让它在shell中进行了快速的测试,并且它可以工作。
I ran python manage.py runserver
with "mysql.connector.django"
as the engine having seen an example here and I got this error:
我跑python管理。与“mysql.connector py runserver。引擎在这里看到了一个例子,我得到了这个错误
django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named mysql.connector.django.base
So I switch back to the default using "django.db.backends.mysql"
as my engine and I get this error:
因此,我使用“django.db.backends”切换回默认值。mysql"作为我的引擎,我得到这个错误:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have no idea how to proceed. I can't install MySQLdb because I'm running my django install under python3 and it's unsupported, but I'm definitely missing something with this connector.
我不知道该怎么办。我不能安装MySQLdb,因为我在python3下运行django安装,它是不受支持的,但是我肯定在这个连接器上漏掉了一些东西。
1 个解决方案
#1
16
For python 2.7, 3.3+ there is a driver called mysqlclient that works with django 1.8
对于python 2.7、3.3+,有一个名为mysqlclient的驱动程序可以使用django 1.8
pip install mysqlclient
And in your settings
和在你的设置
DATABASES = {
'default': {
'NAME': '',
'ENGINE': 'django.db.backends.mysql',
'USER': '',
'PASSWORD': '',
}
}
Here's the official django documentation about the mysql drivers:
下面是关于mysql驱动程序的django官方文档:
https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-db-api-drivers
https://docs.djangoproject.com/en/1.8/ref/databases/ mysql-db-api-drivers
#1
16
For python 2.7, 3.3+ there is a driver called mysqlclient that works with django 1.8
对于python 2.7、3.3+,有一个名为mysqlclient的驱动程序可以使用django 1.8
pip install mysqlclient
And in your settings
和在你的设置
DATABASES = {
'default': {
'NAME': '',
'ENGINE': 'django.db.backends.mysql',
'USER': '',
'PASSWORD': '',
}
}
Here's the official django documentation about the mysql drivers:
下面是关于mysql驱动程序的django官方文档:
https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-db-api-drivers
https://docs.djangoproject.com/en/1.8/ref/databases/ mysql-db-api-drivers