| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Łukasz Jarych <jaryszek(at)gmail(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Requiring pass and database psql shell command |
| Date: | 2018-03-05 14:33:57 |
| Message-ID: | CAKFQuwZfLK8K9M80YW_awa9FBqQV6PkGGcbsnrUQuW6cRS75aw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Mon, Mar 5, 2018 at 5:55 AM, Łukasz Jarych <jaryszek(at)gmail(dot)com> wrote:
> Hi Guys,
>
> do you have also problem that every time you have to log into your
> database using shell and psql?
>
> I have to write over and over localhost, username, password...how to force
> shell to remember this?
>
>
Use a service file.
psql "service=mydb" -c "SELECT 1;"
https://www.postgresql.org/docs/10/static/libpq-pgservice.html
I also, for scripts, simply define a function at the top of the script
psql_* and invoke that function instead of psql directly.
I use .pgpass for passwords
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2018-03-05 15:01:17 | Re: psql variables in the DO command |
| Previous Message | Martin Moore | 2018-03-05 14:27:35 | Re: What is wrong with my pgadmin? |