Skip to content

Use SqlServerContainer with pyodbc driver #244

Open
@gplssm

Description

@gplssm

In fc5f2df#diff-313a71bf8d0b95ccd84a98f198294e10a7c7086c527efb513d9c6619a12086ee the default driver of SqlServerContainer was changed to pymssql.
Currently, I use the pyodbc driver to communicate with MSSQL databases. This is not possible anymore since then. I've tried

test_container = SqlServerContainer(
        image="mcr.microsoft.com/mssql/server:2017-latest",
        dialect="mssql+pyodbc",
    )

which leads to a timeout
testcontainers.core.exceptions.TimeoutException: Wait time (120s) exceeded for _connect(args: (), kwargs {}). Exception: (pyodbc.InterfaceError) ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)')

Alternatively, I've tried to specify the driver

test_container = SqlServerContainer(
        image="mcr.microsoft.com/mssql/server:2017-latest",
        dialect="mssql+pyodbc",
        driver = "ODBC Driver 17 for SQL Server"
    )

but this keyword isn't allowed anymore.
> raise create_unexpected_kwargs_error('run', kwargs) E TypeError: run() got an unexpected keyword argument 'driver'

Is it still the goal of testcontainers to support using the pyodbc driver? If so, I might be motivated to support a little bit making this possible again in 3.6.x versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions