Skip to content

Connect To Database fails with psycopg (v3) due to invalid connection parameter mapping #258

@alsastre

Description

@alsastre

Bug Description

When using Connect To Database with psycopg (psycopg v3), the following error is raised:

ProgrammingError: invalid connection option "database"

Root Cause

The library internally maps the db_name parameter to database when building the connection kwargs. However, psycopg v3 (psycopg==3.x) expects dbname instead of database. This mapping works for other drivers but is incompatible with psycopg3.

Steps to Reproduce

Connect To Database
...    psycopg
...    db_name=mydb
...    db_user=myuser
...    db_password=mypassword
...    db_host=localhost
...    db_port=5432

Environment

  • psycopg==3.3.3
  • psycopg-binary==3.3.3
  • Robot Framework DatabaseLibrary

Expected Behavior

Connect To Database should work with psycopg v3 by using dbname instead of database in the connection kwargs.

Workaround

Using Connect To Database Using Custom Params with explicit psycopg3 parameter names works correctly:

Connect To Database Using Custom Params
...    psycopg
...    dbname='mydb',user='myuser',password='mypassword',host='localhost',port=5432

Suggested Fix

When the connector is psycopg (v3), the internal parameter mapping should use dbname instead of database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions