user529847
user529847

Reputation: 1

How do I change settings.py to migrate from SQLite3 db to a mysql db?

I've included the following in settings.py and local settings.py:

DATABASES = {
    'default': {
        # The last part of ENGINE is 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'ado_mssql'.
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'mydbname'
    'USER': 'myroot',    # Not used with sqlite3.      
        'PASSWORD': '123',        
    }
}

DATABASE_OPTIONS = { "init_command": 'SET NAMES "utf8"' ,  "init_command":'SET storage_engine=INNODB' , }

but I get the following errors when I try to run the server:

Traceback (most recent call last): File "manage.py", line 20, in import settings # Assumed to be in the same directory. File "/usr/home/mydir/settings.py", line 23 'USER': 'myroot', # Not used with sqlite3. ^ SyntaxError: invalid syntax

I'm confused since I've specified that I'm using mysql. Since I was previously using sqlite3, is there something else / some other setting / db routing hierarchy I'm missing?

Upvotes: 0

Views: 840

Answers (2)

locoboy
locoboy

Reputation: 38960

Use a comma at the end and also make sure you install the python-mysql (mysqldb) plugin.

Upvotes: 0

Daniel Roseman
Daniel Roseman

Reputation: 600041

You're missing a comma at the end of the NAME line.

Plus, fix your indentation.

Upvotes: 4

Related Questions