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

use sqlqlchemy_url property in get_uri for mssql provider #39572

Closed
wants to merge 2 commits into from

Conversation

rawwar
Copy link
Collaborator

@rawwar rawwar commented May 12, 2024

related: #38195

use sqlalchemy's URL object to create a URI in the get_uri method.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 28, 2024
@dabla
Copy link
Contributor

dabla commented Jun 28, 2024

I've remarked we had the same issue with SAP Hana and now also with MSSQL, so I started debugging and trying some stuff out. At the end I came up with this solution, and that's patching the following method, which makes it finally work:

 def get_sqlalchemy_engine(self, engine_kwargs=None):
        """
        Get an sqlalchemy_engine object.

        :param engine_kwargs: Kwargs used in :func:`~sqlalchemy.create_engine`.
        :return: the created engine.
        """
        if engine_kwargs is None:
            engine_kwargs = {}
        return create_engine(self.get_uri(), **engine_kwargs)

I've changed it to this:

 def get_sqlalchemy_engine(self, engine_kwargs=None):
        """
        Get an sqlalchemy_engine object.

        :param engine_kwargs: Kwargs used in :func:`~sqlalchemy.create_engine`.
        :return: the created engine.
        """
        if engine_kwargs is None:
            engine_kwargs = {}
        engine_kwargs["creator"] = self.get_conn  # mind here to pass the callable, not the result of get_conn as it will be used internally to create the connection!
        return create_engine(self.get_uri(), **engine_kwargs)

What do you guys think about this solution?

@eladkal eladkal removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Jul 19, 2024
@emredjan
Copy link

emredjan commented Oct 3, 2024

This breaks MS SQL connections if you're using a non-default sqlalchemy scheme (like mssql+pyodbc). See: #42664

@rawwar
Copy link
Collaborator Author

rawwar commented Oct 3, 2024

I am not working on this PR anymore. Closing the PR.

@rawwar rawwar closed this Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants