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 commandthe 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 database with owner equals to that user:
Set credentials in django project settings:
The reason
help
had no effect is that you were already in the middle of writing a command. SQL commands must be terminated by a semicolon. Pay attention to thepsql
prompt - see how it changed from=#
to-#
? That indicates you're in the middle of a command. See In psql, why do some commands have no effect? .If you weren't halfway though a command, typing
help
would've shown:Now... here's the manual for the
psql
command.For summary help on
psql
its self use\?
.For a listing of SQL commands use
\h
.For help on specific commands use
\h COMMAND NAME
e.g.\h CREATE DATABASE
to see how to use theCREATE DATABASE
command. For more details on a command read the manual, e.g. the manual onCREATE DATABASE
.Here's the PostgreSQL tutorial, which covers getting started.