0

This is the settings.py file for python. I set mysql up via macports (mysql5 & mysqldb) The problem is that I am unsure if I have settings.py configuration correct before I sync the db. Should the PORT be left blank? I believe it should. I know on my Mamp install I have it set to 3306. Thanks....

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql'
        'NAME':   'jenniwren'                     # Or path to database file if using sqlite3.
        'USER': '***'                     # Not used with sqlite3.
        'PASSWORD': '****'                  # Not used with sqlite3.
        'HOST': '/var/run/mysql5/mysqld.sock'                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

update: this is what I am getting when I test the db in the shell..

demetrius-fords-macbook-pro-17:jenniwren demet8$ python manage.py dbshell Traceback (most recent call last): File "manage.py", line 4, in import settings # Assumed to be in the same directory. File "/Users/demet8/python_projects/jenniwren/settings.py", line 15 'NAME': 'jenniwren' # Or path to database file if using sqlite3. ^ SyntaxError: invalid syntax

1 Answer 1

1

3306 is the default, so that should be fine.

Why do you have the host set to that? I haven't used MySQL on a Mac, but on Linux the host is 'localhost'.

The 'invalid syntax' is because you do't have a comma after the host string - wait, after any of the strings but the last one - and that is invalid syntax for Python dictionary.

Sign up to request clarification or add additional context in comments.

5 Comments

Alex I fixed the comma situation & left host blank. Unfortunately it's not picking up mysql @localhost. This is definitely due to it being installed via macports. I gotta find the path to mysql5 in opt/local/ & put in in my bash_login file. That should solve the remaining issue. Thank you.
I'm actually installing MacPorts and MySQL on my macbook today, too! If I notice anything about MySQL configuration for Django I'll make a note here.
If you are using MacPorts, you need to ensure that your shell search path includes /opt/local/bin; if you are also using a MacPorts Python, you need to include its bin directory, so something like this: export PATH="/opt/local/bin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:$PATH"
Just FYI: I added this line to my bash_login file & voila it worked! Alex & Ned thanks for your help.... /opt/local/lib/mysql5/bin:
Thanks @demet8, I'll probably need that! I didn't get very far installing mysql on my Mac earlier today...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.