Skip to content

Commit

Permalink
[xy] Decode mysql source bytes. (mage-ai#2176)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaoyou1993 authored Mar 10, 2023
1 parent 3549687 commit 9bf035e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mage_integrations/mage_integrations/sources/sql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from singer.schema import Schema
from time import sleep
from typing import Any, Callable, Dict, Generator, List, Tuple
from typing import Any, Dict, Generator, List, Tuple


class Source(BaseSource):
Expand Down Expand Up @@ -60,10 +60,10 @@ def discover(self, streams: List[str] = None) -> Catalog:
* DATA_TYPE
* IS_NULLABLE
"""
column_key = column_data[2]
column_name = column_data[3]
column_type = column_data[4].lower()
is_nullable = column_data[5]
column_key = self.__decode(column_data[2])
column_name = self.__decode(column_data[3])
column_type = self.__decode(column_data[4].lower())
is_nullable = self.__decode(column_data[5])

column_format = None
column_properties = None
Expand Down Expand Up @@ -251,6 +251,14 @@ def _limit_query_string(self, limit, offset):
def _replication_method(self, stream, bookmarks: Dict = None):
return stream.replication_method

def __decode(self, bytes_or_str):
if type(bytes_or_str) is bytes:
try:
return bytes_or_str.decode('utf-8')
except Exception:
pass
return bytes_or_str

def __fetch_rows(
self,
stream,
Expand Down

0 comments on commit 9bf035e

Please sign in to comment.