B
B
Boldy2015-01-03 16:30:33
MySQL
Boldy, 2015-01-03 16:30:33

How does django "move" from SQLite to MySQL?

Now the project is in SQLite. Task: move to MySQL.
What I did:
1. Installed MySQL sudo apt-get isntall mysql-server
2. Dumped info

python manage.py dumpdata --natural > datadump.json
(without --natural gave
django.db.utils.IntegrityError: Problem installing fixture 'datadump.json': Could not load contenttypes.ContentType(pk=20): (1062, "Duplicate entry 'payments-invitebonus' for key 'django_content_type_app_label_45f3b1d93ec8c61c_uniq'")
)
3. Changed the settings in settings.py to MySQL
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'ppdb',
        'USER': 'dbu',
        'PASSWORD': 'dbp',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    },
}

4. Created a database: create database ppdb charset utf8;
5. I tried to upload data to a fresh database: python manage.py loaddata datadump.json;
As a result, I got
django.db.utils.ProgrammingError: Problem installing fixture 'datadump.json': Could not load auth.User(pk=1): (1146, "Table 'ppdb.auth_user_user_permissions' doesn't exist")

Where did I go wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Abramov, 2015-01-03
@kivsiak

dumpdata only downloads data without structure.
run syncdb first

Z
zelsky, 2015-01-03
@zelsky

look for migrate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question