【问题标题】:Unable to create a connection to a Database that is created by tunneling无法创建与通过隧道创建的数据库的连接
【发布时间】:2019-10-17 00:23:29
【问题描述】:

我在 Robot Framework 中有一个测试用例,我在其中创建了一个隧道,并使用本地主机和隧道端口尝试建立数据库连接,但在尝试运行时出现错误。

Setup failed:
OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno -8] Servname not supported for ai_socktype)")

Also teardown failed:
AttributeError: 'NoneType' object has no attribute 'close'

隧道创建 -

ssh -L 13306:<DB host server Name>:3306 UserName@RemoteMachineHOstName

机器人设置部分-

*** Settings ***
Library  DatabaseLibrary
Test Setup  Connect To Database Using Custom Params  pymysql  'localhost', '13306', 'DBUSERNAME', 'DBPASSWORD', 'DBNAME'
Test Teardown  Disconnect From Database

【问题讨论】:

    标签: database robotframework pymysql


    【解决方案1】:

    没有深入研究 Connect To Database Using Custom Params 关键字,但有一些关于 Robot Framework 的事情:

    1. 无需使用引号来传递字符串。参数始终作为字符串传递。
      所以不要传'localhost',直接用localhost。
    2. 参数由 2 个或更多空格分隔。
      即,去掉那些逗号,。

    试试这个:

    Test Setup  Connect To Database Using Custom Params  pymysql  localhost  13306  DBUSERNAME  DBPASSWORD  DBNAME
    

    注意每个参数之间的 2 个空格。

    【讨论】:

      猜你喜欢
      • 2020-12-19
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-20
      • 2014-09-17
      相关资源
      最近更新 更多