Then, I installed the following needed Python package
sudo apt-get install python3-psycopg2
Then I logged in as postgres user with (CTRL-D to quit)
sudo -u postgres -i
Then,to be able to type SQL commands
psql
which will get the postgres=# command prompt (\q to quit) . Here I did
CREATE DATABASE sudoku;
then
CREATE USER sudoku_user WITH PASSWORD '***********************';
and
GRANT ALL PRIVILEGES ON DATABASE sudoku TO sudoku_user;
Having Django and tests to run
After that, I quit the postgres=# command prompt (\q), then CTRL+D to quit the postgre user and I run the Django migrations
python3 manage.py migrate
Then, finally
python3 manage.py runserver
worked.
To be able to run the tests, additional steps was required in order to allow the test framework to create the test databases for testing purposes. The additional steps are.
Re-login potgres with sudo -u postgres -i and psql
Steps done after checking out the repository
Installation
Installed PostgreSQL
sudo apt install postgresql postgresql-contrib
Then, I installed the following needed Python package
sudo apt-get install python3-psycopg2
Then I logged in as postgres user with (CTRL-D to quit)
sudo -u postgres -i
Then,to be able to type SQL commands
psql
which will get the postgres=# command prompt (\q to quit) . Here I did
CREATE DATABASE sudoku;
thenCREATE USER sudoku_user WITH PASSWORD '***********************';
andGRANT ALL PRIVILEGES ON DATABASE sudoku TO sudoku_user;
Having Django and tests to run
After that, I quit the postgres=# command prompt (\q), then CTRL+D to quit the postgre user and I run the Django migrations
python3 manage.py migrate
Then, finally
python3 manage.py runserver
worked.
To be able to run the tests, additional steps was required in order to allow the test framework to create the test databases for testing purposes. The additional steps are.
sudo -u postgres -i
andpsql
ALTER USER sudoku_user CREATEDB;
DUMP and restore
Login postgres with (CTRL-D to quit)
sudo -u postgres -i
Dump with
pg_dump sudoku > sudoku.dump
The dump file is located at /var/lib/postgresql