Skip to content

Keyword "Connect using custom params" requires quotes (") around the connection string #173

Closed

Description

@amochin

The following example would work:

Connect To Database Using Custom Params    oracledb    "${con_str}"

But if you put no quotation marks around the connection string param, there is an error:

Connect To Database Using Custom Params    oracledb    ${con_str}

In order to avoid the backwards incompatibility, the code should be improved in the way that both options (with and without quotes) work.

Here is a full example for the oracle database:

*** Variables ***
${DBHost}       127.0.0.1
${DBName}       MY_DB
${DBPass}       pass
${DBPort}       1521
${DBUser}       db_user

*** Keywords ***
Connect To DB
    ${con_str} =    Catenate    SEPARATOR=${EMPTY}
    ...    ${DBUser}/${DBPass}@
    ...    ${DBHost}:${DBPort}/${DBName}
    Connect To Database Using Custom Params    oracledb    "${con_str}"

Activity

  1. added this to the v1.3.0 milestone on Jun 7, 2023
  2. self-assigned this
    on Jun 13, 2023
  3. added 3 commits that reference this issue on Jun 13, 2023
    042c08f
    c96f464
    29169b7
  4. amochin commented on Jun 14, 2023

    @amochin
    CollaboratorAuthor

    It turns out to be not a bug, but a feature :)
    The keyword "Connect To Database Using Custom Params" was not supposed to work with pure connections strings / URI's, having all connection values in one string.

    Instead, it Interprets the db_connect_string parameter value as a list of named arguments, which would be passed to the "connect" function of the selected db module. Example for psycopg2:
    database='my_db_test', user='postgres', password='s3cr3t', host='tiger.foobar.com', port=5432

    So I left the keyword basically in the original state, just slightly improved the code and the docs.

    But I've also added a new keyword Connect To Database Using Custom Connection String - it's designed to work with combined connection strings / URI's like this:
    postgresql://postgres:s3cr3t@tiger.foobar.com:5432/my_db_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions