Re: request for feature: psql 'DSN' option - Mailing list pgsql-hackers

From Chris Browne
Subject Re: request for feature: psql 'DSN' option
Date
Msg-id 60sllds9ck.fsf@dba2.int.libertyrms.com
Whole thread Raw
In response to request for feature: psql "DSN" option  (Christopher Browne <cbbrowne@acm.org>)
List pgsql-hackers
david@fetter.org (David Fetter) writes:
> On Fri, Jul 07, 2006 at 05:33:14AM -0500, Andrew Dunstan wrote:
>> Christopher Browne said:
>> >
>> > The notion:  Plenty of libraries out there like Pg, DBI::Pg, and such
>> > make you specify connections in the form:
>> >   "host=my.db.host.example.org port=5678 dbname=dumb_db user=chewie"
>> 
>> Why is this better than using the service file?
>
> What Andrew asked.

It's not *better* than PGSERVICE; it's just that this does reflect the
connection representation widely used by every sort of library out
there that uses libpq.

Let's do a quick "guess the language"...

Which language is this? conn = PGconn.open("host=my.db.host.example.org port=5678 dbname=dumb_db user=chewie");

How about this? $conn = Pg::connectdb("host=my.db.host.example.org port=5678 dbname=dumb_db user=chewie");

Hmm...  This one should be easy to guess... import psycopg2  dbcon = psycopg2.connect('host=my.db.host.example.org
port=5678dbname=dumb_db user=chewie')
 

This one might conceivably be easy to mistake for another... $dbconn = pg_connect("host=my.db.host.example.org
port=5678dbname=dumb_db user=chewie")    or die('Could not connect: ' . pg_last_error());
 

How about this? set conres [catch {set newdbc [pg_connect -conninfo          "host=my.db.host.example.org port=5678
dbname=dumb_dbuser=chewie"]} msg]
 

This isn't as obvious as it may seem... (setq P (pq-connectdb "host=my.db.host.example.org port=5678 dbname=dumb_db
user=chewie"))

But this probably is... (setf conn (postgresql::PQconnectdb "host=my.db.host.example.org port=5678 dbname=dumb_db
user=chewie"))

Gavin would be extremely disappointed if I had left this one out :-) let main () =   let c = new connection
~conninfo:"host=my.db.host.example.orgport=5678 dbname=dumb_db user=chewie" () in   let _ = c#exec ~expect:[Copy_in]
("copy" ^ Sys.argv.(1) ^ " from stdin") in   c#copy_in_channel stdin;   c#finish
 

The common thing across all of these is that there's a single string
passed in to request the connection.  A string that libpq in effect
requires, but which psql, somewhat oddly, does not allow you to
directly specify.

We've had cases where we needed to store pgconn "connection
signatures", for reports, and then discovered we wanted to use them to
describe psql connections.

A "--pgconn" or "-D" option would allow doing this.

I agree that pg_service.conf is probably cleaner, but it seems
somewhat odd for The Poster Child libpq application, psql, *not* to
have a way of passing in a conninfo value.
-- 
let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;;
http://cbbrowne.com/info/oses.html
If a mute swears, does his mother wash his hands with soap? 


pgsql-hackers by date:

Previous
From: "Diogo Biazus"
Date:
Subject: Re: xlog viewer prototype and new proposal
Next
From: Martijn van Oosterhout
Date:
Subject: Re: xlog viewer prototype and new proposal