Problems with Django, when installing the cymysql plugin to connect to the database

0

What I am using:

  • Operating system: Debian 9
  • Database: MySQL 5.5
  • Django 1.11.4

I execute the command:

python manage.py migrate

The following error message is displayed in the terminal:

django.core.exceptions.ImproperlyConfigured: 'mysql_cymysql' isn't an 

available database backend.

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

Error was: No module named cymysql

When installing cymysql with the command:

pip install cymysql

If I run in% mode,% co shows:

Requirement already satisfied: cymysql in /usr/local/lib/python2.7/dist-packages.

In root I have installed

django-cymysql==2.0.0

pip freeze is not installed.

The cymysql file is configured as follows:

DATABASES = {
    'default': {
        'ENGINE': 'mysql_cymysql',
        'NAME': 'nombre_base_de_datos',
        'USER': 'root',
        'PASSWORD': '*******',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

The content of settings.py is:

from __future__ import unicode_literals
from django.db import models


class Formulario(models.Model):
  # parametros
  # parametros
  # parametros
    
asked by Developer 28.02.2018 в 04:46
source

1 answer

2

Friend, I suggest you use mysqlclient == 1.3.12 that works for both maridb and mysql:

pip instal mysqlclient==1.3.12

Then in the settings:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'tubasededatos',
        'USER': 'tuusuario',
        'PASSWORD': 'tupassword',
        'HOST': 'localhost',
        'PORT': '',
        'OPTIONS' :  { 
            'init_command' :  "SET sql_mode = 'STRICT_TRANS_TABLES'" , 
        }, 
    }
}

If you are not using virtualenv I recommend it since you can work with multiple django projects with different versions on the same computer.

    
answered by 28.02.2018 / 21:21
source