Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#192 connection() does not match API standards [it does]

MySQLdb-1.2
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2006-06-30
Scott Jackson
No

conn =
MySQLdb.connection('foo',user='scott',password="password")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'password' is an invalid keyword argument
for this function

for the python DB API:
http://www.python.org/dev/peps/pep-0249/
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)

Therefore the keyword for "password" should be
"password" and not "passwd", database should be
"database" and not "db"

I can't seem to set the severity, but this is mostly a
cosmetic error, but could lead to blockers in
applications that expect their database libraries to
match a strict API...

Discussion

  • Andy Dustman
    Andy Dustman
    2006-06-30

    Logged In: YES
    user_id=71372

    The operative word is "guideline".

    Applications that are expecting the database libraries to
    matchc a strict API are badly designed because PEP-249 is
    NOT script wrt connections. It specifically says:

        connect(parameters...)
    
            Constructor for creating a connection to the
    

    database.
    Returns a Connection Object. It takes a number of
    parameters which are database dependent. [1]

    The operative phrase there is "database dependent".

    If some future version of the DB-API requires this
    arragement, then I'll change it. Until then, no.