R
R
Ruben Harutyunov2014-02-26 14:22:26
MySQL
Ruben Harutyunov, 2014-02-26 14:22:26

How to solve the problem when connecting MySQLdb to Django?

I need to use MySQL instead of sqlite. I wrote this in settings.py:

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

But when syncing I get the following error:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

Installed python-mysqldb, but the problem was not solved. What have I done wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
maxaon, 2014-02-26
@K_DOT

Try to install dev dependencies.
Also check if you are executing commands in the virtualenv ( is displayed before the input line)

S
Stoned Shaman, 2014-03-16
@StonedShaman

I encountered the same on arch (python3.3, django 1.6, mariadb 5.5).
The following helped:
using PyMySQL, because Google suggested that mysql-python does not work with python3
Next, in the __init__.py of the application (INSTALLED_APPS), add:

import pymysql
pymysql.install_as_MySQLdb()

P
Pan Propan, 2016-02-23
@mgis

Help solve this problem on Windows 10

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question