When the 'port' argument is set in call to MySQLdb.connect() this exception is shown(shortened):
File "E:\Python22\Lib\site-packages\MySQLdb\connections.py", line 41, in _make_connection
apply(super(ConnectionBase, self).__init__, args, kwargs)
TypeError: connect() argument 2 must be string, not int
If the number is changed to a string the exception reads:
(shortened)
File "E:\Python22\Lib\site-packages\MySQLdb\connections.py", line 41, in _make_connection
apply(super(ConnectionBase, self).__init__, args, kwargs)
TypeError: an integer is required
Solution?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When the 'port' argument is set in call to MySQLdb.connect() this exception is shown(shortened):
File "E:\Python22\Lib\site-packages\MySQLdb\connections.py", line 41, in _make_connection
apply(super(ConnectionBase, self).__init__, args, kwargs)
TypeError: connect() argument 2 must be string, not int
If the number is changed to a string the exception reads:
(shortened)
File "E:\Python22\Lib\site-packages\MySQLdb\connections.py", line 41, in _make_connection
apply(super(ConnectionBase, self).__init__, args, kwargs)
TypeError: an integer is required
Solution?
It would be helpful to see the entire call you are making to connect as well as the types and values of each argument to the call...
Greg
Here is the code for the call:
try:
conn = MySQLdb.connect( self._dbConnInfo.host,
self._dbConnInfo.port,
self._dbConnInfo.user,
self._dbConnInfo.password,
self._dbConnInfo.db )
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit(1)
I have also used values directly, both string and int, and also have tried to coerce values using str() and int().
Thanks for looking at this.
You'll need to use named parameters.
MySQLdb.connect(user=username,passwd=password,db=database,host=hostname,port=req_port)