Lookaway CMS Database Configuration - Postgresql 10

Documented by kbruder tech✞ᵀᵀᴹ on Oct 08, 2020
Last updated on Mar 22, 2021


Postgresql Logo

Introduction

In this example we will switch to the Postgres user which was created when Postgesql 10 was installed. Make sure Postgresql 10 is installed before proceeding. It's a good idea to open a new terminal then log out and close it after the database configuration is confirmed to be working.


  1. Switch to the Postgresql user and enter the Postgres CLI

    Use the following commands to enter the Postgres command line interface

    $ sudo -u postgres psql
    

  2. Create the Lookaway Database

    Use the following commands in the Postgres CLI to create a new database.

    postgres=# create database lookaway;
    

  3. Create the Lookaway Database Role

    Use the following command in the Postgres CLI to create a Lookaway database role.

    postgres=# create role lookaway;
    

  4. Authorize the Lookaway Database Role

    Use the following command on the Postgres CLI to authorize the Lookaway role to use the database.

    postgres=# grant all privileges on database lookaway to lookaway;
    postgres=# alter role lookaway with encrypted password '<PASSWORD>';
    postgres=# alter role lookaway with login;
    postgres=# alter role lookaway createdb;
    

  5. Django PostgreSQL Database Requirements

    Follow Django's own recommendations for using PostgreSQL

    postgres=# alter role lookaway set client_encoding to 'utf8';
    postgres=# alter role lookaway set default_transaction_isolation to 'read committed';
    postgres=# alter role lookaway set timezone to 'UTC';
    

    Django needs the following parameters for its database connections: client_encoding: 'UTF8', default_transaction_isolation: 'read committed' by default, or the value set in the connection options (see below), timezone: when USE_TZ is True, 'UTC' by default, or the TIME_ZONE value set for the connection, when USE_TZ is False, the value of the global TIME_ZONE setting. If these parameters already have the correct values, Django won’t set them for every new connection, which improves performance slightly. You can configure them directly in postgresql.conf or more conveniently per database user with ALTER ROLE. Django will work just fine without this optimization, but each new connection will do some additional queries to set these parameters.
    Source: Django

  6. Close the Terminal

    Use the following command to quit the Postgres CLI then close the terminal.

    postgres=# \q
    

Conclusion

Now Postgresql is setup to allow Lookaway CMS to read and write its own database and create new ones for testing purposes.


Referenced by

Lookaway CMS Production Server - Ubuntu 20

Learn how to deploy Lookaway CMS onto a public webserver using Ubuntu 20.04 and PostgreSQL 10.

Recovering From Backup Data - Lookaway CMS

This document explains how to recover your Lookaway CMS powered website from backup data.

Lookaway CMS Initialization - Ubuntu 20

Learn how to initialize all of the modules, files, and configurations for a fresh production Lookaway CMS installation on a server running Ubuntu Server 20

bitcoin:3MnhNRKgrpTFQWstYicjF6GebY7u7dap4u
Bitcoin Accepted Here

3MnhNRKgrpTFQWstYicjF6GebY7u7dap4u

Please donate some Bitcoin to our site. We can use it to keep improving the site and open up to more members. Any amount will help. Thank you.


litecoin:MT61gm6pdp9rJoLyMWW5A1hnUpxAERnxqg
Litecoin Accepted Here

MT61gm6pdp9rJoLyMWW5A1hnUpxAERnxqg

Please donate some Lite to our site. We can use it to keep improving the site and open it up to more members. Any amount will help. Thank you.