Hello I'm new in postgreSQL,Please guide me a bit
I have a django project
here is settings.py :
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "testfor_psl",
"USER": "",
"PASSWORD": "",
"HOST": "localhost",
"PORT": "",
}
}
And I run python manage.py syncdb
There is error:OperationalError: FATAL: database "testfor_psl" does not exist
So how can I create db??
I use posgreSQL.app, and click the Open psql
There is a terminal like this :
I type help
,and nothing happen.
Please help me. Thanks
You need to put ;
at the end of psql commad. As you can see, after command
winsome=# CREATE DATABASE testfor_psl
the prompt is changed from =#
to -#
. It means, that psql still wait for the command to be completed by providing ;
.
Also, it is better to create a database user for django project. So here what you need to do:
Create user in database (in psql):
CREATE USER testfor_psl_user WITH password 'pass';
Create database with owner equals to that user:
CREATE DATABASE testfor_psl ENCODING 'UTF8' TEMPLATE template0 OWNER testfor_psl_user;
Set credentials in django project settings:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "testfor_psl",
"USER": "testfor_psl_user",
"PASSWORD": "pass",
"HOST": "localhost",
"PORT": "5432", # default port
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With