【问题标题】:AssertionError: PORT is not a number (in Python)AssertionError: PORT 不是数字(在 Python 中)
【发布时间】:2020-07-19 05:07:39
【问题描述】:

当我使用 ssh 隧道访问 mySQL 数据库时,为什么总是在 remote_bind_address 上显示此错误?

AssertionError: PORT is not a number

这是我的代码:

with SSHTunnelForwarder(
        (self.ssh_host, self.ssh_port),  # Remote server IP and SSH port
        ssh_username=self.ssh_username,
        ssh_private_key=self.ssh_pkey,
        remote_bind_address=(self.host_mysql, self.port_mysql)
        ) as server:
        server.start()  # start ssh sever
        print('Server connected via SSH') 
        local_port = str(server.local_bind_port)

任何人都可以帮助我吗?谢谢之前

【问题讨论】:

标签: python mysql python-3.x mysql-python ssh-tunnel


【解决方案1】:

可能发生错误是因为您提供的端口是字符串类型而不是 int。通过在有问题的行之前打印type(self.port_mysql) 来检查它。

【讨论】:

    猜你喜欢
    • 2013-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多