[DB-SIG] URI syntax for databases

Ian Bicking ianb at colorstudy.com
Wed Mar 30 22:40:38 CEST 2005


M.-A. Lemburg wrote:
> This doesn't strike me as very Pythonic. The DB API spec specifies a
> set of keyword parameters that cover most usage scenarios already:
> 
>         As a guideline the connection constructor parameters should be
>         implemented as keyword parameters for more intuitive use and
>         follow this order of parameters:
> 
>         dsn         Data source name as string
>         user        User name as string (optional)
>         password    Password as string (optional)
>         host        Hostname (optional)
>         database    Database name (optional)
> 
>         E.g. a connect could look like this:
> 
>         connect(dsn='myhost:MYDB',user='guido',password='234$')
> 
> Your syntax seems to be more geared torwards an abstract
> interface to databases, which is - as you say - one level
> above the DB API spec.
> 
> It should be rather simple to write a factory function which
> takes your syntax and then imports the right module, translates
> the parameters and connects to the database.

This isn't meant to replace the current connect function, just augment 
it.  I would expect that implementations would specifically translate 
URIs into a connect invocation.  However, it would be useful if this was 
distributed with drivers, since there's no a general way to map URIs to 
connections for all databases.  If it's not part of drivers, then I'll 
just make a separate library to do this so other people can use it, but 
it won't (at least initially) support drivers I don't use (which happens 
to include mxODBC among others).

I have also noticed that connect functions are rather poorly documented 
for many drivers, so my implementation might not be accurate.

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the DB-SIG mailing list