Skip to content

Transformation tool does not use correct connection string for SQL Server #150

@carlfischerjba

Description

@carlfischerjba

Issue Description

When reading exposure data from a SQL Server database using a custom port, the connection fails.

Steps to Reproduce (Bugs only)

Here's the config file.

transformations:
  loc: # Transformation name
    input_format:
      name: Cede_Location
      version: 10.0.0
    output_format:
      name: OED_Location
      version: 3.0.2
    runner:
      batch_size: 750000 # Number of rows to process in a single batch
    extractor:
      type: mssql # Path to the DB connection file. Other options are 'postgres' and 'sqlite'. Defaults to 'csv', when not present.
      options:
        host: myserver
        port: 1450
        database: MY_DB
        user: foo
        password: bar
        sql_statement: ./cede_location.sql # SQL statement to extract data
    loader:
      options:
        path: ./CF_oed_location.csv # Path to the output file
        quoting: minimal

And the command used:

ods_tools transform --config-file /path/to/CF_config.yaml

The output is:

2024-10-28 16:18:13,612 - ERROR - DBConnectionError(), line 160 in /home/carl/venvs/myvenv/lib/python3.10/site-packages/ods_tools/odtf/controller.py

Version / Environment information

  • ods-tools 3.2.5

Example data / logs

This can be fixed by setting the port as part of the server string:

        host: myserver,1450
        port:

But would perhaps be better done in code at

"DRIVER={};SERVER={};PORT={};DATABASE={};UID={};PWD={}".format(
.

            conn = pyodbc.connect(
                "DRIVER={};SERVER={},{};DATABASE={};UID={};PWD={}".format(
                    self.driver,
                    database["host"],
                    database["port"],
                    database["database"],
                    database["user"],
                    database["password"],
                )
            )

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

On Hold

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions