[DB-SIG] PEP 249
Sigurd Jervelund Hansen
sigurd at jervelund.com
Fri Jun 24 10:31:10 EDT 2016
Hi
I'm using the PEP249 as a reference, and I've stumbled upon some
contradicting documentation in footnote 1.
If I attempt to connect to a database using the example I get the following
error:
>>> connect(host=dbHost,user=dbUser,password=dbPassword,database=dbName)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/__init__.py", line
81, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py",
line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'database' is an invalid keyword argument for this function
Changing parameter database to db:
>>> connect(host=dbHost,user=dbUser,password=dbPassword,db=dbName)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/__init__.py", line
81, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py",
line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'password' is an invalid keyword argument for this function
Changing parameter password to passwd:
>>> connect(host=dbHost,user=dbUser,passwd=dbPassword,db=dbName)
<_mysql.connection open to 'mysql-host' at 217e660>
In short: Parameter password should be passwd and database should be db.
Direct link to footnote <https://mail.google.com/>:
https://www.python.org/dev/peps/pep-0249/#id40
Link to stackoverflow with working example:
http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python
Best regards
Sigurd J. Hansen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20160624/75f08af7/attachment.html>
More information about the DB-SIG
mailing list