Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 8bbe841

Browse files
authored
Merge pull request #109 from datafold/cleanup_june27
Small cleanup
2 parents 75b8c5d + 1da627a commit 8bbe841

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

data_diff/databases/mssql.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
class MsSQL(ThreadedDatabase):
2-
"AKA sql-server"
1+
# class MsSQL(ThreadedDatabase):
2+
# "AKA sql-server"
33

4-
def __init__(self, host, port, user, password, *, database, thread_count, **kw):
5-
args = dict(server=host, port=port, database=database, user=user, password=password, **kw)
6-
self._args = {k: v for k, v in args.items() if v is not None}
4+
# def __init__(self, host, port, user, password, *, database, thread_count, **kw):
5+
# args = dict(server=host, port=port, database=database, user=user, password=password, **kw)
6+
# self._args = {k: v for k, v in args.items() if v is not None}
77

8-
super().__init__(thread_count=thread_count)
8+
# super().__init__(thread_count=thread_count)
99

10-
def create_connection(self):
11-
mssql = import_mssql()
12-
try:
13-
return mssql.connect(**self._args)
14-
except mssql.Error as e:
15-
raise ConnectError(*e.args) from e
10+
# def create_connection(self):
11+
# mssql = import_mssql()
12+
# try:
13+
# return mssql.connect(**self._args)
14+
# except mssql.Error as e:
15+
# raise ConnectError(*e.args) from e
1616

17-
def quote(self, s: str):
18-
return f"[{s}]"
17+
# def quote(self, s: str):
18+
# return f"[{s}]"
1919

20-
def md5_to_int(self, s: str) -> str:
21-
return f"CONVERT(decimal(38,0), CONVERT(bigint, HashBytes('MD5', {s}), 2))"
22-
# return f"CONVERT(bigint, (CHECKSUM({s})))"
20+
# def md5_to_int(self, s: str) -> str:
21+
# return f"CONVERT(decimal(38,0), CONVERT(bigint, HashBytes('MD5', {s}), 2))"
22+
# # return f"CONVERT(bigint, (CHECKSUM({s})))"
2323

24-
def to_string(self, s: str):
25-
return f"CONVERT(varchar, {s})"
24+
# def to_string(self, s: str):
25+
# return f"CONVERT(varchar, {s})"

data_diff/databases/oracle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,26 @@ def _parse_type(
7777
r"TIMESTAMP\((\d)\) WITH LOCAL TIME ZONE": Timestamp,
7878
r"TIMESTAMP\((\d)\) WITH TIME ZONE": TimestampTZ,
7979
}
80-
for regexp, cls in regexps.items():
80+
for regexp, t_cls in regexps.items():
8181
m = re.match(regexp + "$", type_repr)
8282
if m:
8383
datetime_precision = int(m.group(1))
84-
return cls(
84+
return t_cls(
8585
precision=datetime_precision if datetime_precision is not None else DEFAULT_DATETIME_PRECISION,
8686
rounds=self.ROUNDS_ON_PREC_LOSS,
8787
)
8888

89-
cls = {
89+
n_cls = {
9090
"NUMBER": Decimal,
9191
"FLOAT": Float,
9292
}.get(type_repr, None)
93-
if cls:
94-
if issubclass(cls, Decimal):
93+
if n_cls:
94+
if issubclass(n_cls, Decimal):
9595
assert numeric_scale is not None, (type_repr, numeric_precision, numeric_scale)
96-
return cls(precision=numeric_scale)
96+
return n_cls(precision=numeric_scale)
9797

98-
assert issubclass(cls, Float)
99-
return cls(
98+
assert issubclass(n_cls, Float)
99+
return n_cls(
100100
precision=self._convert_db_precision_to_digits(
101101
numeric_precision if numeric_precision is not None else DEFAULT_NUMERIC_PRECISION
102102
)

data_diff/databases/presto.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,30 @@ def _parse_type(
8282
r"timestamp\((\d)\)": Timestamp,
8383
r"timestamp\((\d)\) with time zone": TimestampTZ,
8484
}
85-
for regexp, cls in timestamp_regexps.items():
85+
for regexp, t_cls in timestamp_regexps.items():
8686
m = re.match(regexp + "$", type_repr)
8787
if m:
8888
datetime_precision = int(m.group(1))
89-
return cls(
89+
return t_cls(
9090
precision=datetime_precision if datetime_precision is not None else DEFAULT_DATETIME_PRECISION,
9191
rounds=False,
9292
)
9393

9494
number_regexps = {r"decimal\((\d+),(\d+)\)": Decimal}
95-
for regexp, cls in number_regexps.items():
95+
for regexp, n_cls in number_regexps.items():
9696
m = re.match(regexp + "$", type_repr)
9797
if m:
9898
prec, scale = map(int, m.groups())
99-
return cls(scale)
99+
return n_cls(scale)
100100

101-
cls = self.NUMERIC_TYPES.get(type_repr)
102-
if cls:
103-
if issubclass(cls, Integer):
101+
n_cls = self.NUMERIC_TYPES.get(type_repr)
102+
if n_cls:
103+
if issubclass(n_cls, Integer):
104104
assert numeric_precision is not None
105-
return cls(0)
105+
return n_cls(0)
106106

107-
assert issubclass(cls, Float)
108-
return cls(
107+
assert issubclass(n_cls, Float)
108+
return n_cls(
109109
precision=self._convert_db_precision_to_digits(
110110
numeric_precision if numeric_precision is not None else DEFAULT_NUMERIC_PRECISION
111111
)

0 commit comments

Comments
 (0)