Answer the question
In order to leave comments, you need to log in
Django. How to connect to an existing MySQL model?
There is a mysql database on the disk. I can’t figure out what to use to connect with, or it django-admin.py syncdb
throws errors like this:
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
django-admin.py migrate
DATABASES = {
'default': {
'NAME': '/usr/local/var/mysql/Didondo',
'ENGINE': 'django.db.backends.mysql',
'USER': 'root',
'PASSWORD': '',
'OPTIONS': {
'autocommit': True,
'HOST' : 'localhost',
'PORT' : ' ',
}
}
}
Answer the question
In order to leave comments, you need to log in
manage.py syncdb - synchronize models with the database.
Install lib:
sudo apt-get install python-mysqldb
1. First create the database manually on the Mysql server.
2. Specify the name of the database in NAME, not the full path to the database, 'NAME': 'Didondo',
3. add PASSWORD if it is installed in Mysql.
4. Run manage.py syncdb
PS manage.py migrate runs migrations if set to South
'Error loading MySQLdb module' - The mysql-python module or similar was not installed. You may need dev packages.
Under Windows, I did this:
1. Launched OpenServer (which I already had installed for PHP)
2. Registered in the "settings.py" file of the project:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'example.python',
'USER': 'root',
'PASSWORD': '',
}
}
python manage.py runserver
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question