Re: database "cdf_100_1313" does not exist

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: database "cdf_100_1313" does not exist
Дата
Msg-id 525385a5-c69e-47dd-9e33-0640cc6fc165@manitou-mail.org
обсуждение исходный текст
Ответ на Re: database "cdf_100_1313" does not exist  (nikhil raj <nikhilraj474@gmail.com>)
Список pgsql-general
    nikhil raj wrote:

> /usr/lib/postgresql/11/bin/psql -p 5432 -U postgres -d $DBLIST -c "GRANT
> CONNECT ON DATABASE \"$DBLIST\" TO cpupdate"
> ERROR:  database " CDF_100_1313" does not exist

That's because you don't use the unaligned format to get the
list of results. You should add -A to psql options.

Or better yet, use a simpler method that does not use
shell variables at all and work with a single psql call:

$ psql -U postgres -d postgres <<EOF

select format('GRANT CONNECT ON DATABASE %I TO cpupdate',
    datname) FROM pg_database WHERE <insert conditions here>
\gexec

EOF

That's possible because you don't need to be connected to
a database to grant the right to connect to that database.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



В списке pgsql-general по дате отправления:

Предыдущее
От: nikhil raj
Дата:
Сообщение: Re: database "cdf_100_1313" does not exist
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Permissions on postgresql.conf, psql and patroni