简体   繁体   English

错误:无节:使用DatabaseLibrary的Robot Framework中的“默认”

[英]Error: No section: 'default' in Robot Framework using DatabaseLibrary

I am using Robot Framework with Database Library to test database queries on localhost. 我正在使用带有数据库库的Robot Framework在本地主机上测试数据库查询。 I am running it by XAMPP. 我正在XAMPP上运行它。
This is my test case: 这是我的测试用例:

*** Settings ***
Library           DatabaseLibrary

*** Variables ***
@{DB}             robotframework    root    \    localhost    3306

*** Test Cases ***
Select from database
    [Tags]    This
    Connect To Database    MySQLdb    @{DB}[0]    @{DB}[1]    @{DB}[2]    @{DB}[3]    @{DB}[4]
    @{results}=    Query    Select * From tbName
    Log Many    @{results}

I have installed MySQLDb for Python 2.7, however, when I run it using pybot, it keeps returning error: 我已经为Python 2.7安装了MySQLDb,但是,当我使用pybot运行它时,它总是返回错误:
Select from database | 从数据库中选择| FAIL | 失败|
NoSectionError: No section: 'default' NoSectionError:无节:'默认'
Please help me to solve this problem. 请帮我解决这个问题。 Thanks. 谢谢。

You should check the content of dbConfigFile. 您应该检查dbConfigFile的内容。 You don't specify one so the default one is ./resources/db.cfg. 您没有指定一个,所以默认的是./resources/db.cfg。

The error says when python try to parse that file it cannot find a section named default. 该错误表明,当python尝试解析该文件时,它找不到名为default的部分。 In documentation it says: 在文档中说:

note: specifying dbapiModuleName, dbName dbUsername or dbPassword directly will override the properties of the same key in dbConfigFile 注意:直接指定dbapiModuleName,dbName,dbUsername或dbPassword将覆盖dbConfigFile中相同键的属性。

so even if you specify all properties it reads config file. 因此,即使您指定了所有属性,它也会读取配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM