Skip to content

Allow to use dialect mssql+pyodbc - #298

Open
gplssm wants to merge 7 commits into
testcontainers:mainfrom
gplssm:feature/SqlServerContainer-with-driver-option
Open

gplssm wants to merge 7 commits into
testcontainers:mainfrom
gplssm:feature/SqlServerContainer-with-driver-option

Conversation

@gplssm

@gplssm gplssm commented Jan 23, 2023 •

Copy link
Copy Markdown

Closes #244

@gplssm
gplssm marked this pull request as ready for review January 23, 2023 16:11
Comment thread mssql/testcontainers/mssql/__init__.py Outdated
Comment on lines +68 to +69
if len(drivers) > 0:
driver_str = drivers[0].replace(" ", "+")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hunch is that this won't work because sorted is an iterable that can't be indexed. We likely also need to parse the version as an integer because, using string comparison, version 8 is greater than version 10. E.g.,

>>> max(['ODBC Driver 10 for SQL Server', 'ODBC Driver 8 for SQL Server'])
'ODBC Driver 8 for SQL Server'


r = re.compile(r"ODBC Driver \d{1,2} for SQL Server")
# We sort drivers in reversed order to get the latest
drivers = sorted(list(filter(r.match, pyodbc.drivers())), reverse=True)

@tillahoffmann tillahoffmann Feb 16, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to convert to int first. We can probably just use max here rather than sorting and taking the first.

@tillahoffmann

Copy link
Copy Markdown
Contributor

The test fails because Literal is not available in python 3.7 (cf python/typing#707). As 3.7 is close to end of life, let's omit the Literal typing for now, and we can re-introduce it once we drop support for python 3.7.

@tillahoffmann tillahoffmann linked an issue Feb 16, 2023 that may be closed by this pull request
@alexanderankin alexanderankin added the 👥 community feat feature but its a community module so we wont bump tc core for it label Mar 26, 2024

This branch has not been deployed

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

Labels

👥 community feat feature but its a community module so we wont bump tc core for it 📦 package: mssql

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use SqlServerContainer with pyodbc driver Installation with poetry and mssqlserver extra broken

3 participants