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

Commit 3ee4945

Browse files
committed
Refactor database.py -> databases/*.py, each db gets a file.
1 parent bcafe20 commit 3ee4945

23 files changed

+996
-979
lines changed

data_diff/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Tuple, Iterator, Optional, Union
22

3-
from .database import connect_to_uri
3+
from .databases.connect import connect_to_uri
44
from .diff_tables import (
55
TableSegment,
66
TableDiffer,
@@ -9,7 +9,6 @@
99
DbKey,
1010
DbTime,
1111
DbPath,
12-
parse_table_name,
1312
)
1413

1514

@@ -18,10 +17,11 @@ def connect_to_table(
1817
):
1918
"""Connects to a URI and creates a TableSegment instance"""
2019

20+
db = connect_to_uri(db_uri, thread_count=thread_count)
21+
2122
if isinstance(table_name, str):
22-
table_name = parse_table_name(table_name)
23+
table_name = db.parse_table_name(table_name)
2324

24-
db = connect_to_uri(db_uri, thread_count=thread_count)
2525
return TableSegment(db, table_name, key_column, **kwargs)
2626

2727

data_diff/__main__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
TableDiffer,
1010
DEFAULT_BISECTION_THRESHOLD,
1111
DEFAULT_BISECTION_FACTOR,
12-
parse_table_name,
1312
)
14-
from .database import connect_to_uri, parse_table_name
13+
from .databases.connect import connect_to_uri
1514
from .parse_time import parse_time_before_now, UNITS_STR, ParseError
1615

1716
import rich
@@ -104,7 +103,7 @@ def main(
104103
try:
105104
threads = int(threads)
106105
except ValueError:
107-
logger.error("Error: threads must be a number, 'auto', or 'serial'.")
106+
logging.error("Error: threads must be a number, 'auto', or 'serial'.")
108107
return
109108
if threads < 1:
110109
logging.error("Error: threads must be >= 1")
@@ -129,8 +128,8 @@ def main(
129128
logging.error("Error while parsing age expression: %s" % e)
130129
return
131130

132-
table1 = TableSegment(db1, parse_table_name(table1_name), key_column, update_column, columns, **options)
133-
table2 = TableSegment(db2, parse_table_name(table2_name), key_column, update_column, columns, **options)
131+
table1 = TableSegment(db1, db1.parse_table_name(table1_name), key_column, update_column, columns, **options)
132+
table2 = TableSegment(db2, db2.parse_table_name(table2_name), key_column, update_column, columns, **options)
134133

135134
differ = TableDiffer(
136135
bisection_factor=bisection_factor,

0 commit comments

Comments
 (0)