in reply to Re^2: Database access and async web framework (like Mojolicious)
in thread Database access and async web framework (like Mojolicious)

Still looking how to login as admin

The postgres O/S user should be able to do that locally without a pw (initially at least). From there you can start assigning roles and auth as you please.


🦛

Replies are listed 'Best First'.
Re^4: Database access and async web framework (like Mojolicious)
by bliako (Abbot) on Dec 18, 2024 at 09:57 UTC

    ok, thanks, i am doing that. su is my friend.

      bummer, I need to double quote all my existing db-ops scripts to account for the extra 'su -c ...' and just now I found that 'create database' does not support 'IF NOT EXIST' and that I have to go in a huge roundabout involving some creature called \gexec which after an hour I found out it is not supported in 'psql -c ...'. Hey I think I have found in PG a new sadomasochistic group. Whips! yummy not.

      Edit: psql -Upostgres will run the commands via the 'postgres' linux user. I thought it runs the SQL commands via a db user. OK now I can avoid the constant su but I have to enter password all the time! So better running the script via su -c db-init-script.sh - postgres.

        OK, it seems I had some progress sanEtising my interactions with postgres and psql, its sql shell.

        Once I create a database and a database user I no longer need to use the "postgres" linux account to run commands via su thanks to the "service file". This is a simple configuration file which holds dbname, dbuser, pass etc.:

        # located at x/y/z.config [myservice] host= port= # above 2 can be left empty to denote unix socket connection dbname=... user=... password=...

        And then PGSERVICEFILE=x/y/z.config psql 'service=myservice'

        I have also found that psql accepts a connection string like: sql 'postgresql://mydbuser:mypassword@host:port/mydbname' (host, port are optional, leave empty for unix socket connection)

        Hey I think I have found in PG a new sadomasochistic group. Whips! yummy not.

        Haha! True, but once you are initiated, you'll be hooked. I know I was when this girlfriend of mine introduced me to bonding, but I digress.

        Postgresql's documentation is outstanding, and very easy to search. I suggest you invest some time to get the hang of it, by reading Chapter I Tutorial and investigating Chapter VI Reference, which will cover most your needs.

        The pgsql-general list is very active, you'll get all the help you need there, providing you did basic research. I've been reading it every day for twenty years, I learn something new every time.

        Marica : Logiciel de gestion des contentieux juridiques, des contrats et des sinistres d'assurance