Syntax Error when trying to migrate to Postgresql

77 views
Skip to first unread message

Joe

unread,
Feb 13, 2018, 7:17:43 PM2/13/18
to Django users
I have installed django, Postgresql, and psycopg2 and went to migrate a project to a new database I created on postgresql, This is the error message I got. 

Traceback (most recent call last):

  File "manage.py", line 15, in <module>

    execute_from_command_line(sys.argv)

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line

    utility.execute()

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/site-packages/django/core/management/__init__.py", line 317, in execute

    settings.INSTALLED_APPS

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__

    self._setup(name)

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup

    self._wrapped = Settings(settings_module)

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__

    mod = importlib.import_module(self.SETTINGS_MODULE)

  File "/Users/JosephConrad/Desktop/Joetestsite/lib/python3.6/importlib/__init__.py", line 126, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 978, in _gcd_import

  File "<frozen importlib._bootstrap>", line 961, in _find_and_load

  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 674, in exec_module

  File "<frozen importlib._bootstrap_external>", line 781, in get_code

  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code

  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed

  File "/Users/JosephConrad/Desktop/Joetestsite/MySite/BudgetSite/settings.py", line 77

    ‘postgresql’: {

               ^

SyntaxError: invalid character in identifier



I am able to migrate with sqllite but I can't migrate to postgresql.

Andy

unread,
Feb 14, 2018, 3:58:59 AM2/14/18
to Django users
Could you post a few more lines of this settings.py? Preferably the whole DATABASES definition.

Just in case there actually is a weird invisible character try retyping 'postgresql', but more likely it looks as if you are using wrong quotation marks other than ' or ". I dont even have on my keyboard whats in your error message.

Joe

unread,
Feb 14, 2018, 5:32:51 PM2/14/18
to Django users

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': ‘postgres’,
        'USER': ‘postgres’,
        'PASSWORD': ‘*’,
        'HOST': ‘localhost’,
        'PORT': ‘8000’,

Larry Martell

unread,
Feb 14, 2018, 5:41:24 PM2/14/18
to django...@googlegroups.com
On Wed, Feb 14, 2018 at 5:32 PM, Joe <joe.ten...@gmail.com> wrote:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': ‘postgres’,
> 'USER': ‘postgres’,
> 'PASSWORD': ‘*’,
> 'HOST': ‘localhost’,
> 'PORT': ‘8000’,
> }
> }

Looks like the quotes around the values are some non ascii character.
On my screen I see this:



Change it to ' or "

Did you copy/paste that from Word perhaps?

Joe

unread,
Feb 14, 2018, 9:59:06 PM2/14/18
to Django users
I used TextEdit on Mac to edit the files, maybe using a different editor would work better.

Joe

unread,
Feb 14, 2018, 10:12:55 PM2/14/18
to Django users
The problem was with the quotes being weird format, had to copy and paste the correct quotes in for it.  Thanks for the help!!

PASCUAL Eric

unread,
Feb 17, 2018, 7:06:07 AM2/17/18
to Django users

Office oriented editors tend to take initiatives for making the text prettier (at least, according to their "standards" 😊).


For programming tasks, you'd better use real programming editors. There are a lot of very good ones which are free, and even full IDEs. I'd strongly suggest PyCharm Community Edition in this category (I'm not endorsed by JetBrain and have no connection at all with them, apart from being a very happy user of their products).


Best


Eric

From: django...@googlegroups.com <django...@googlegroups.com> on behalf of Joe <joe.ten...@gmail.com>
Sent: Thursday, February 15, 2018 4:12:54 AM
To: Django users
Subject: Re: Syntax Error when trying to migrate to Postgresql
 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/872de896-e541-466b-a158-5bcc59e7914b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages