[DB-SIG] URI syntax for databases
M.-A. Lemburg
mal at egenix.com
Wed Mar 30 22:50:10 CEST 2005
Ian Bicking wrote:
> 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.
What we could add an optional keyword argument uri="..." which
database could then interpret according to your suggestion.
This would be backwards compatible with the existing DB API.
However, I don't see why the scheme name should be the name
of the database module... I'd opt for "dbapi2:" as scheme -
after all, that's what the protocol scheme is all about ;-)
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Mar 30 2005)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the DB-SIG
mailing list