Skip to content

Commit

Permalink
Merge pull request #84 from dbeatty10/feature/adapter-response
Browse files Browse the repository at this point in the history
Report status as `SUCCESS` instead of `Unknown cursor state/status`
  • Loading branch information
dbeatty10 authored Mar 13, 2022
2 parents e3437d0 + cc97991 commit 1cf0dcf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased (TBD)
- Support dbt v0.20.0 ([#83](https://github.com/dbeatty10/dbt-mysql/pull/83))
- Report status as `SUCCESS` instead of `Unknown cursor state/status` ([#84](https://github.com/dbeatty10/dbt-mysql/pull/84))

## dbt-mysql 0.19.2 (March 12, 2022)
- Support dbt v0.19.2 ([#81](https://github.com/dbeatty10/dbt-mysql/pull/81))
Expand Down
18 changes: 9 additions & 9 deletions dbt/adapters/mariadb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@ def exception_handler(self, sql):

raise dbt.exceptions.RuntimeException(e) from e

@classmethod
def get_status(cls, cursor):
# There's no real way to get this from mysql-connector-python.
# So just return "OK".
return "OK"

@classmethod
def get_response(cls, cursor) -> AdapterResponse:
code = "Unknown cursor state/status"
code = "SUCCESS"
num_rows = 0

if cursor is not None and cursor.rowcount is not None:
num_rows = cursor.rowcount

# There's no real way to get the status from the mysql-connector-python driver.
# So just return the default value.
return AdapterResponse(
_message="{} {}".format(code, cursor.rowcount),
rows_affected=cursor.rowcount,
_message="{} {}".format(code, num_rows),
rows_affected=num_rows,
code=code
)
18 changes: 9 additions & 9 deletions dbt/adapters/mysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,18 @@ def exception_handler(self, sql):

raise dbt.exceptions.RuntimeException(e) from e

@classmethod
def get_status(cls, cursor):
# There's no real way to get this from mysql-connector-python.
# So just return "OK".
return "OK"

@classmethod
def get_response(cls, cursor) -> AdapterResponse:
code = "Unknown cursor state/status"
code = "SUCCESS"
num_rows = 0

if cursor is not None and cursor.rowcount is not None:
num_rows = cursor.rowcount

# There's no real way to get the status from the mysql-connector-python driver.
# So just return the default value.
return AdapterResponse(
_message="{} {}".format(code, cursor.rowcount),
rows_affected=cursor.rowcount,
_message="{} {}".format(code, num_rows),
rows_affected=num_rows,
code=code
)
18 changes: 9 additions & 9 deletions dbt/adapters/mysql5/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,18 @@ def exception_handler(self, sql):

raise dbt.exceptions.RuntimeException(e) from e

@classmethod
def get_status(cls, cursor):
# There's no real way to get this from mysql-connector-python.
# So just return "OK".
return "OK"

@classmethod
def get_response(cls, cursor) -> AdapterResponse:
code = "Unknown cursor state/status"
code = "SUCCESS"
num_rows = 0

if cursor is not None and cursor.rowcount is not None:
num_rows = cursor.rowcount

# There's no real way to get the status from the mysql-connector-python driver.
# So just return the default value.
return AdapterResponse(
_message="{} {}".format(code, cursor.rowcount),
rows_affected=cursor.rowcount,
_message="{} {}".format(code, num_rows),
rows_affected=num_rows,
code=code
)

0 comments on commit 1cf0dcf

Please sign in to comment.