Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: MSSQL (SqlServerContainer) ignores some parameters #736

Open
meiswjn opened this issue Nov 14, 2024 · 0 comments
Open

Bug: MSSQL (SqlServerContainer) ignores some parameters #736

meiswjn opened this issue Nov 14, 2024 · 0 comments

Comments

@meiswjn
Copy link
Contributor

meiswjn commented Nov 14, 2024

Describe the bug

When running the SqlServerContainer, in this example with the image mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04, some parameters have no effect on the actual database and lead to failures. It seems like they are just not respected.

To Reproduce

import sqlalchemy
from testcontainers.mssql import SqlServerContainer

def test_showcase_bug():
    with SqlServerContainer(image="mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04", username="dummy") as mssql:
        engine = sqlalchemy.create_engine(mssql.get_connection_url()) # this includes the username "dummy" now.
        print(mssql.get_connection_url())
        with engine.begin() as connection:
            result = connection.execute(sqlalchemy.text("select @@VERSION"))

It loads a while. When looking at the database logs, it prints:

2024-11-14 10:39:43.81 Logon       Error: 18456, Severity: 14, State: 5.
2024-11-14 10:39:43.81 Logon       Login failed for user 'dummy'. Reason: Could not find a login matching the name provided. [CLIENT: 172.17.0.3]

Same thing for other parameters, for example db_name.

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

Windows 11
Python 3.11.9
testcontainers 4.8.2
sqlalchemy 2.0.36
pymssql 2.3.1

Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant