After updating to Version 1.23.1 PyMySQL throws "port should be of type int":
Traceback (most recent call last):
File "/nix/store/hr12pxbvgddw7mhnpsk88h8yydrbbl64-mycli-1.23.1/lib/python3.8/site-packages/mycli/main.py", line 447, in connect
_connect()
File "/nix/store/hr12pxbvgddw7mhnpsk88h8yydrbbl64-mycli-1.23.1/lib/python3.8/site-packages/mycli/main.py", line 424, in _connect
self.sqlexecute = SQLExecute(
File "/nix/store/hr12pxbvgddw7mhnpsk88h8yydrbbl64-mycli-1.23.1/lib/python3.8/site-packages/mycli/sqlexecute.py", line 63, in __init__
self.connect()
File "/nix/store/hr12pxbvgddw7mhnpsk88h8yydrbbl64-mycli-1.23.1/lib/python3.8/site-packages/mycli/sqlexecute.py", line 121, in connect
conn = pymysql.connect(
File "/nix/store/3fxbd88721pi5v8b8sz6z46gxpm7jmrq-python3.8-PyMySQL-0.10.1/lib/python3.8/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/nix/store/3fxbd88721pi5v8b8sz6z46gxpm7jmrq-python3.8-PyMySQL-0.10.1/lib/python3.8/site-packages/pymysql/connections.py", line 258, in __init__
raise ValueError("port should be of type int")
ValueError: port should be of type int
I then added some debugging outputs:
1.23.1
cnf = self.read_my_cnf_files(self.cnf_files, cnf.keys())
print("# cnf:", cnf)
# Fall back to config values only if user did not specify a value.
database = database or cnf['database']
print("# arguments of connect():")
print("# host:", host)
print("# port:", port)
print("# ssh_host:", ssh_host)
print("# ssh_port:", ssh_port)
print("# if port or (host and host != 'localhost') or (ssh_host and ssh_port):")
# Socket interface not supported for SSH connections
if port or (host and host != 'localhost') or (ssh_host and ssh_port):
print("# true => setting socket to empty string")
socket = ''
else:
print("# false => setting socket to socket, cnf.socket or guess_socket_location()")
socket = socket or cnf['socket'] or guess_socket_location()
user = user or cnf['user'] or os.getenv('USER')
host = host or cnf['host']
port = port or cnf['port']
ssl = ssl or {}
print("# final socket:", socket)
print("# final host:", host)
print("# final port:", port)
(v1.23.1) $ ./result/bin/mycli
# cnf: {'database': None, 'user': 'root', 'password': None, 'host': None, 'port': '3306', 'socket': '/var/run/mysqld/mysqld.sock', 'default-character-set': 'utf8mb4', 'local-infile': None, 'loose-local-infile': None, 'ssl-ca': None, 'ssl-cert': None, 'ssl-key': None, 'ssl-cipher': None, 'ssl-verify-serer-cert': None}
# arguments of connect():
# host: None
# port: None
# ssh_host: None
# ssh_port: 22
# if port or (host and host != 'localhost') or (ssh_host and ssh_port):
# false => setting socket to socket, cnf.socket or guess_socket_location()
# final socket: /var/run/mysqld/mysqld.sock
# final host: None
# final port: 3306
Connecting to socket /var/run/mysqld/mysqld.sock, owned by user mysql
port should be of type int
When explicitly setting "--port 3306" the connection succeeds:
(v1.23.1) $ ./result/bin/mycli --port 3306
# cnf: {'database': None, 'user': 'root', 'password': None, 'host': None, 'port': '3306', 'socket': '/var/run/mysqld/mysqld.sock', 'default-character-set': 'utf8mb4', 'local-infile': None, 'loose-local-infile': None, 'ssl-ca': None, 'ssl-cert': None, 'ssl-key': None, 'ssl-cipher': None, 'ssl-verify-serer-cert': None}
# arguments of connect():
# host: None
# port: 3306
# ssh_host: None
# ssh_port: 22
# if port or (host and host != 'localhost') or (ssh_host and ssh_port):
# true => setting socket to empty string
# final socket:
# final host: None
# final port: 3306
mariadb root@localhost:(none)>
1.22.2
On 1.22.2 this error did not occur and i was able to connect without explicitly adding "--port 3306":
cnf = self.read_my_cnf_files(self.cnf_files, cnf.keys())
print("# cnf:", cnf)
# Fall back to config values only if user did not specify a value.
database = database or cnf['database']
print("# arguments of connect():")
print("# host:", host)
print("# port:", port)
print("# ssh_host:", ssh_host)
print("# ssh_port:", ssh_port)
print("# if port or host or ssh_host or ssh_port:")
# Socket interface not supported for SSH connections
if port or host or ssh_host or ssh_port:
print("# true => setting socket to empty string")
socket = ''
else:
print("# false => setting socket to socket, cnf.socket or guess_socket_location()")
socket = socket or cnf['socket'] or guess_socket_location()
user = user or cnf['user'] or os.getenv('USER')
host = host or cnf['host']
port = port or cnf['port']
ssl = ssl or {}
print("# final socket:", socket)
print("# final host:", host)
print("# final port:", port)
(v1.22.2) $ ./result/bin/mycli
# cnf: {'database': None, 'user': 'root', 'password': None, 'host': None, 'port': '3306', 'socket': '/var/run/mysqld/mysqld.sock', 'default-character-set': 'utf8mb4', 'local-infile': None, 'loose-local-infile': None, 'ssl-ca': None, 'ssl-cert': None, 'ssl-key': None, 'ssl-cipher': None, 'ssl-verify-serer-cert': None}
# arguments of connect():
# host: None
# port: None
# ssh_host: None
# ssh_port: 22
# if port or host or ssh_host or ssh_port:
# true => setting socket to empty string
# final socket:
# final host: None
# final port: 3306
mariadb root@localhost:(none)>
After updating to Version 1.23.1
PyMySQL
throws "port should be of type int":I then added some debugging outputs:
1.23.1
When explicitly setting "--port 3306" the connection succeeds:
1.22.2
On 1.22.2 this error did not occur and i was able to connect without explicitly adding "--port 3306":