On Tue, Dec 07, 2004 at 12:38:53PM -0500, Mark Stosberg wrote:
> On Tue, Dec 07, 2004 at 12:38:12PM +0000, Tim Bunce wrote:
> > 
> > ---
> > The simplest fix is to standardize one set of driver DSN attribute
> > names so that at least the host, port, and database (schema) can
> > be specified in a portable way.
> > 
> > Most drivers already support the "foo=bar;..."  style in the DSN string.
> > They'd just need to support alternative names for some attributes.
> > 
> > As for what names to use, "host" and "port" are easy choices.
> > For the database there's "db", "dbname", and "database".
> > I'd probably go with "db".
> > ---
> > 
> > So now what all you zelots out there need to do is (gently) nag the
> > authors of your favorite drivers to implement this change.
> > 
> > The most gentle and effective way of doing that is to send them a patch.
> 
> Shouldn't DBI proper at least have a documentation patch explaining what
> which parts of this should be considered 'standard'? 

Of course. I was already working on it:

@@ -2415,10 +2500,14 @@
 driver is free to use whatever syntax it wants. The only requirement the
 DBI makes is that all the information is supplied in a single string.
 You must consult the documentation for the drivers you are using for a
-description of the syntax they require. (Where a driver author needs
-to define a syntax for the C<$data_source>, it is recommended that
-they follow the ODBC style, shown in the last example above.)
+description of the syntax they require.

+It is recommended that drivers support the ODBC style, shown in the
+last example above. It is also recommended that that they support the
+three common names 'C<host>', 'C<port>', and 'C<database>' (plus 'C<db>'
+as an alias for C<database>). This simplifies automatic construction
+of basic DSNs: C<"dbi:$driver:database=$db;host=$host;port=$port">.
+
 If the environment variable C<DBI_AUTOPROXY> is defined (and the
 driver in C<$data_source> is not "C<Proxy>") then the connect request
 will automatically be changed to:

[The line numbers of the patch don't match the latest release due
to other changes, but this is in the DBI->connect docs.]

> I see that each DBD module can translate the hash into an old-fashioned
> DSN string themselves.

I have no plans to add dsn-as-a-hash to the DBI.

Tim.

p.s. I've removed [EMAIL PROTECTED] from the CC list.

Reply via email to