pgtcl way of specifying a user

Started by Patrick Nelsonabout 23 years ago5 messagesgeneral
Jump to latest
#1Patrick Nelson
pnelson@neatech.com

I have cron and init scripts that call my PostgreSQL db for their data.
This worked fine until I moved the sql server off the system. Then I had to
specify the actual host and user in the case of pg_dumpall called from a tcl
script. Cron wasn't grabbing the proper variables of PGHOST PGUSER I guess.
No problem, just added them to the command of pg_dumpall and the script
works fine

I have another script that uses libpgtcl and this script runs as part of
init level 3 or level 5. It also don't connect to the database by utilizing
any variables in a .bash_profile config file. I can not figure out how to
make the connection. I used:

pg_connect $PGDBName -host $PGHostName

and this works, but I don't know what user it will use as part of init and I
can not figure out how to define a user. Can anyone shad some light on my
problems. IWAI

#2Nicolas Boretos
nicolasb@maich.gr
In reply to: Patrick Nelson (#1)
Re: pgtcl way of specifying a user

Patrick Nelson wrote:

I have cron and init scripts that call my PostgreSQL db for their data.
This worked fine until I moved the sql server off the system. Then I had to
specify the actual host and user in the case of pg_dumpall called from a tcl
script. Cron wasn't grabbing the proper variables of PGHOST PGUSER I guess.
No problem, just added them to the command of pg_dumpall and the script
works fine

I have another script that uses libpgtcl and this script runs as part of
init level 3 or level 5. It also don't connect to the database by utilizing
any variables in a .bash_profile config file. I can not figure out how to
make the connection. I used:

pg_connect $PGDBName -host $PGHostName

Try pg_connect $PGDBName -host $PGHostName -username Bob -password Secret

regards,

nicolas boretos

Show quoted text

and this works, but I don't know what user it will use as part of init and I
can not figure out how to define a user. Can anyone shad some light on my
problems. IWAI

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

.

#3Patrick Nelson
pnelson@neatech.com
In reply to: Nicolas Boretos (#2)
Re: pgtcl way of specifying a user

Nicolas Boretos wrote:
----------------->>>>
Try pg_connect $PGDBName -host $PGHostName -username Bob -password Secret
----------------->>>>

-username and -password are not options of pg_connect and result in an
error. That's the problem there seems to be no way of specifying a specific
user.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Patrick Nelson (#3)
Re: pgtcl way of specifying a user

Patrick Nelson <pnelson@neatech.com> writes:

-username and -password are not options of pg_connect and result in an
error. That's the problem there seems to be no way of specifying a specific
user.

Use the pg_connect -conninfo style, -conninfo "user=foo dbname=bar ..."
The other syntax is obsolete and not really being supported.

regards, tom lane

#5Patrick Nelson
pnelson@neatech.com
In reply to: Tom Lane (#4)
Re: pgtcl way of specifying a user [SOLVED]

Tom Lane wrote:
----------------->>>>
Use the pg_connect -conninfo style, -conninfo "user=foo dbname=bar ..."
The other syntax is obsolete and not really being supported.
----------------->>>>

The following solved my problem:

pg_connect -conninfo "host=$PGHostName user=$PGUserName dbname=$PGDBName"