feldroy / django-crash-course

The issue tracker and code repository for Django Crash Course
https://www.feldroy.com/products/django-crash-course
144 stars 30 forks source link

invalid SQL executed in section 18.5 #337

Open mathemaat opened 4 years ago

mathemaat commented 4 years ago

Location within the Book

Description

I've followed all instructions to the book and left all cookiecutter settings at the default. Unfortunately the SQL I have to execute in section 18.5 is invalid.

(dcc-cheese) [mschwartz@marc-pc everycheese]$ python manage.py sqlcreate | sudo -u postgres psql -U postgres
[sudo] password for mschwartz: 
could not change directory to "/home/mschwartz/Documents/programming/everycheese": Permission denied
ERROR:  syntax error at or near "WITH"
LINE 1: CREATE USER  WITH ENCRYPTED PASSWORD '' CREATEDB;
                     ^
ERROR:  zero-length delimited identifier at or near """"
LINE 1: CREATE DATABASE everycheese WITH ENCODING 'UTF-8' OWNER "";
                                                                ^
ERROR:  syntax error at or near ";"
LINE 1: GRANT ALL PRIVILEGES ON DATABASE everycheese TO ;
                                                        ^
(dcc-cheese) [mschwartz@marc-pc everycheese]$ python manage.py sqlcreate
CREATE USER  WITH ENCRYPTED PASSWORD '' CREATEDB;
CREATE DATABASE everycheese WITH ENCODING 'UTF-8' OWNER "";
GRANT ALL PRIVILEGES ON DATABASE everycheese TO ;

Possible Solutions

No idea yet. I will retrace my steps to figure out where it goes wrong.

Your full name

Marc Schwartz

mathemaat commented 4 years ago

So I retraced my steps from the start, but the end result was the same. I've managed to work around it though, so I can continue with chapter 19 now.

hlsautter commented 4 years ago

I have the same issue on macOS. How did you work around it?

(everycheese) hsautter@MacBook everycheese % python manage.py sqlcreate | psql
ERROR: syntax error at or near "WITH" LINE 1: CREATE USER WITH ENCRYPTED PASSWORD '' CREATEDB; ^ ERROR: zero-length delimited identifier at or near """" LINE 1: CREATE DATABASE everycheese WITH ENCODING 'UTF-8' OWNER ""; ^ ERROR: syntax error at or near ";" LINE 1: GRANT ALL PRIVILEGES ON DATABASE everycheese TO ; ^

luzfcb commented 4 years ago

@mathemaat @hlsautter Please, test https://github.com/feldroy/django-crash-course/issues/320#issuecomment-665086071

hlsautter commented 4 years ago

I got past the issue with the createdb command

(everycheese) hsautter@MacBook everycheese % createdb everycheese
(everycheese) hsautter@MacBook everycheese % python manage.py migrate
Operations to perform: Apply all migrations: account, admin, auth, contenttypes, sessions, sites, socialaccount, users Running migrations: Applying contenttypes.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0001_initial... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying users.0001_initial... OK Applying account.0001_initial... OK Applying account.0002_email_max_length... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying sessions.0001_initial... OK Applying sites.0001_initial... OK Applying sites.0002_alter_domain_unique... OK Applying sites.0003_set_site_domain_and_name... OK Applying socialaccount.0001_initial... OK Applying socialaccount.0002_token_max_lengths... OK Applying socialaccount.0003_extra_data_default_dict... OK (everycheese) hsautter@MacBook everycheese % python manage.py runserver Watching for file changes with StatReloader INFO 2020-08-22 19:00:16,362 autoreload 10736 4452777408 Watching for file changes with StatReloader Performing system checks...

System check identified no issues (0 silenced). August 22, 2020 - 19:00:16 Django version 3.0.9, using settings 'config.settings.local' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.