Podłączanie mysql do Django (Python 3.3)

Odpowiedz Nowy wątek
2015-12-16 01:17
0

Witam.
Mam takie zapytanko. Próbuję podłączyć bazę mysql do mojej aplikacji w django i mam problem. Dowiedziałem się, że muszę używać mysql-connector-django. No to zainstalowałem używając easy_install (hosting vipserv.org). Ustawienia w settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'xxx',
        'USER': 'xxx',
        'PASSWORD': 'xxx',
        'HOST': 'mysql5',
        'PORT': '',
    }
}

Dodałem do INSTALLED_APPS:
'mysql.connector.django',
ale coś mi nie trybi. Error logi passengera:
Traceback (most recent call last):
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/share/Python-3.3.1/lib/python3.3/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1583, in _gcd_import
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1564, in _find_and_load
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1531, in _find_and_load_unlocked
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1023, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1004, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 869, in _load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 313, in _call_with_frames_removed
File "/home/csnajper/site-packages/mysql_connector_python-2.0.4-py3.3.egg/mysql/connector/django/base.py", line 50, in <module>
from django.db.backends import (BaseDatabaseFeatures, BaseDatabaseOperations,
ImportError: cannot import name BaseDatabaseFeatures

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/passenger-4.0.59/helper-scripts/wsgi-loader.py", line 320, in <module>
app_module = load_app()
File "/usr/passenger-4.0.59/helper-scripts/wsgi-loader.py", line 61, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "/usr/share/Python-3.3.1/lib/python3.3/imp.py", line 114, in load_source
return _LoadSourceCompatibility(name, pathname, file).load_module(name)
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1023, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1004, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 869, in _load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 313, in _call_with_frames_removed
File "passenger_wsgi.py", line 15, in <module>
application = ErrorMiddlewareV.EMV(get_wsgi_application(), True)
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/share/Python-3.3.1/lib/python3.3/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1583, in _gcd_import
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1564, in _find_and_load
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1531, in _find_and_load_unlocked
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1023, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 1004, in load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 869, in _load_module
File "<frozen importlib._bootstrap="importlib._bootstrap">", line 313, in _call_with_frames_removed
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/contrib/auth/models.py", line 41, in <module>
class Permission(models.Model):
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/models/base.py", line 139, in new
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/models/options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/init.py", line 36, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/utils.py", line 240, in getitem
backend = load_backend(db['ENGINE'])
File "/home/csnajper/site-packages/Django-1.8.3-py3.3.egg/django/db/utils.py", line 129, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'mysql.connector.django' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name BaseDatabaseFeatures

edytowany 1x, ostatnio: kondzixd, 2015-12-16 01:17

Pozostało 580 znaków

2015-12-16 10:50
Świetny Samiec
0

Try using 'django.db.backends.XXX', where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'

Na moje oko, za dużo tych XXX- ów, wydaje się, że nie wypełniłeś wszystkich pól w settings.

Pozostało 580 znaków

2015-12-16 16:33
0

Wypełniłem, ale django.db.backends.mysql nie współpracuje z pythonem 3.3+ więc muszę skorzystać z innych opcji.

Pozostało 580 znaków

2015-12-16 18:33
Krwawy Terrorysta
0

Tu masz odpowiedź na SO: http://stackoverflow.com/ques[...]etting-django-up-to-use-mysql

Pozostało 580 znaków

Odpowiedz
Liczba odpowiedzi na stronę

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0