Re: request for feature: psql 'DSN' option

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: request for feature: psql 'DSN' option
Date: 2006-07-07 15:50:03
Message-ID: 60sllds9ck.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

david(at)fetter(dot)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=5678 dbname=dumb_db user=chewie')

This one might conceivably be easy to mistake for another...
$dbconn = pg_connect("host=my.db.host.example.org port=5678 dbname=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_db user=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.org port=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?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-07-07 16:05:53 Re: xlog viewer prototype and new proposal
Previous Message Diogo Biazus 2006-07-07 14:59:41 Re: xlog viewer prototype and new proposal