Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt/adapters/sqlserver/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.4"
version = "1.8.5"
55 changes: 7 additions & 48 deletions dbt/adapters/sqlserver/sqlserver_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from dbt.adapters.fabric.fabric_connection_manager import (
AZURE_CREDENTIAL_SCOPE,
bool_to_connection_string_arg,
get_pyodbc_attrs_before,
get_pyodbc_attrs_before_accesstoken,
get_pyodbc_attrs_before_credentials,
)

from dbt.adapters.sqlserver import __version__
Expand Down Expand Up @@ -70,27 +71,6 @@ def get_sp_access_token(credentials: SQLServerCredentials) -> AccessToken:
class SQLServerConnectionManager(FabricConnectionManager):
TYPE = "sqlserver"

# @contextmanager
# def exception_handler(self, sql: str):
# """
# Returns a context manager, that will handle exceptions raised
# from queries, catch, log, and raise dbt exceptions it knows how to handle.
# """
# # ## Example ##
# # try:
# # yield
# # except myadapter_library.DatabaseError as exc:
# # self.release(connection_name)

# # logger.debug("myadapter error: {}".format(str(e)))
# # raise dbt.exceptions.DatabaseException(str(exc))
# # except Exception as exc:
# # logger.debug("Error running SQL: {}".format(sql))
# # logger.debug("Rolling back transaction.")
# # self.release(connection_name)
# # raise dbt.exceptions.RuntimeException(str(exc))
# pass

@classmethod
def open(cls, connection: Connection) -> Connection:
if connection.state == ConnectionState.OPEN:
Expand Down Expand Up @@ -156,7 +136,11 @@ def open(cls, connection: Connection) -> Connection:
def connect():
logger.debug(f"Using connection string: {con_str_display}")

attrs_before = get_pyodbc_attrs_before(credentials)
if credentials.authentication == "ActiveDirectoryAccessToken":
attrs_before = get_pyodbc_attrs_before_accesstoken(credentials.access_token)
else:
attrs_before = get_pyodbc_attrs_before_credentials(credentials)

handle = pyodbc.connect(
con_str_concat,
attrs_before=attrs_before,
Expand All @@ -174,28 +158,3 @@ def connect():
retry_limit=credentials.retries,
retryable_exceptions=retryable_exceptions,
)

# @classmethod
# def get_response(cls,cursor):
# """
# Gets a cursor object and returns adapter-specific information
# about the last executed command generally a AdapterResponse ojbect
# that has items such as code, rows_affected,etc. can also just be a string ex. "OK"
# if your cursor does not offer rich metadata.
# """
# # ## Example ##
# # return cursor.status_message
# pass

# def cancel(self, connection):
# """
# Gets a connection object and attempts to cancel any ongoing queries.
# """
# # ## Example ##
# # tid = connection.handle.transaction_id()
# # sql = "select cancel_transaction({})".format(tid)
# # logger.debug("Cancelling query "{}" ({})".format(connection_name, pid))
# # _, cursor = self.add_query(sql, "master")
# # res = cursor.fetchone()
# # logger.debug("Canceled query "{}": {}".format(connection_name, res))
# pass
4 changes: 2 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dbt.adapters.sqlserver.sqlserver_connections import ( # byte_array_to_datetime,
bool_to_connection_string_arg,
get_pyodbc_attrs_before,
get_pyodbc_attrs_before_credentials,
)
from dbt.adapters.sqlserver.sqlserver_credentials import SQLServerCredentials

Expand All @@ -29,7 +29,7 @@ def test_get_pyodbc_attrs_before_empty_dict_when_service_principal(
"""
When the authentication is set to sql we expect an empty attrs before.
"""
attrs_before = get_pyodbc_attrs_before(credentials)
attrs_before = get_pyodbc_attrs_before_credentials(credentials)
assert attrs_before == {}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dbt.adapters.sqlserver.sqlserver_connections import ( # byte_array_to_datetime,
bool_to_connection_string_arg,
get_pyodbc_attrs_before,
get_pyodbc_attrs_before_credentials,
)
from dbt.adapters.sqlserver.sqlserver_credentials import SQLServerCredentials

Expand All @@ -29,7 +29,7 @@ def test_get_pyodbc_attrs_before_empty_dict_when_service_principal(
"""
When the authentication is set to sql we expect an empty attrs before.
"""
attrs_before = get_pyodbc_attrs_before(credentials)
attrs_before = get_pyodbc_attrs_before_credentials(credentials)
assert attrs_before == {}


Expand Down