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

Commit 4f2c7aa

Browse files
authored
Merge pull request #726 from datafold/fix_conn_attrib_postgres
'PostgreSQL' object has no attribute '_conn'
2 parents 943d128 + 33bfbd7 commit 4f2c7aa

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

data_diff/__main__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ def main(conf, run, **kw):
327327
)
328328
except Exception as e:
329329
logging.error(e)
330-
if kw["debug"]:
331-
raise
330+
raise
332331

333332

334333
def _data_diff(

data_diff/databases/postgresql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ def create_connection(self):
147147

148148
pg = import_postgresql()
149149
try:
150-
c = pg.connect(**self._args)
150+
self._conn = pg.connect(**self._args)
151151
if SESSION_TIME_ZONE:
152-
c.cursor().execute(f"SET TIME ZONE '{SESSION_TIME_ZONE}'")
153-
return c
152+
self._conn.cursor().execute(f"SET TIME ZONE '{SESSION_TIME_ZONE}'")
153+
return self._conn
154154
except pg.OperationalError as e:
155155
raise ConnectError(*e.args) from e
156156

tests/test_cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111

1212
def run_datadiff_cli(*args):
1313
try:
14-
stdout = subprocess.check_output(
15-
[sys.executable, "-m", "data_diff", "--no-tracking"] + list(args), stderr=subprocess.PIPE
14+
p = subprocess.Popen(
15+
[sys.executable, "-m", "data_diff", "--no-tracking"] + list(args),
16+
stdout=subprocess.PIPE,
17+
stderr=subprocess.PIPE,
1618
)
19+
stdout, stderr = p.communicate()
1720
except subprocess.CalledProcessError as e:
1821
logging.error(e.stderr)
1922
raise
23+
if stderr:
24+
raise Exception(stderr)
2025
return stdout.splitlines()
2126

2227

@@ -48,6 +53,7 @@ def setUp(self) -> None:
4853
def test_basic(self):
4954
conn_str = CONN_STRINGS[self.db_cls]
5055
diff = run_datadiff_cli(conn_str, self.table_src_name, conn_str, self.table_dst_name)
56+
5157
assert len(diff) == 1
5258

5359
def test_options(self):

0 commit comments

Comments
 (0)