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

Commit 85f5610

Browse files
authored
Merge pull request #325 from datafold/issue317
Better error messages in databases; Default database in clickhouse is now 'default'.
2 parents e367da4 + 0c32cd9 commit 85f5610

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

data_diff/__main__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,11 @@ def _main(
307307
)
308308
return
309309

310-
try:
311-
db1 = connect(database1, threads1 or threads)
312-
if database1 == database2:
313-
db2 = db1
314-
else:
315-
db2 = connect(database2, threads2 or threads)
316-
except Exception as e:
317-
logging.error(e)
318-
return
310+
db1 = connect(database1, threads1 or threads)
311+
if database1 == database2:
312+
db2 = db1
313+
else:
314+
db2 = connect(database2, threads2 or threads)
319315

320316
now: datetime = db1.query(current_timestamp(), datetime)
321317
now = now.replace(tzinfo=None)

data_diff/sqeleton/databases/clickhouse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424
from ..abcs.mixins import AbstractMixin_MD5, AbstractMixin_NormalizeValue
2525

26+
DEFAULT_DATABASE = "default" # https://clickhouse.com/docs/en/operations/server-configuration-parameters/settings/#default-database
2627

2728
@import_helper("clickhouse")
2829
def import_clickhouse():
@@ -164,7 +165,7 @@ def __init__(self, *, thread_count: int, **kw):
164165

165166
self._args = kw
166167
# In Clickhouse database and schema are the same
167-
self.default_schema = kw["database"]
168+
self.default_schema = kw.get("database", DEFAULT_DATABASE)
168169

169170
def create_connection(self):
170171
clickhouse = import_clickhouse()

data_diff/sqeleton/databases/mysql.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def __init__(self, *, thread_count, **kw):
111111
super().__init__(thread_count=thread_count)
112112

113113
# In MySQL schema and database are synonymous
114-
self.default_schema = kw["database"]
114+
try:
115+
self.default_schema = kw["database"]
116+
except KeyError:
117+
raise ValueError("MySQL URL must specify a database")
115118

116119
def create_connection(self):
117120
mysql = import_mysql()

0 commit comments

Comments
 (0)