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

'PostgreSQL' object has no attribute '_conn' #726

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions data_diff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ def main(conf, run, **kw):
)
except Exception as e:
logging.error(e)
if kw["debug"]:
raise
raise


def _data_diff(
Expand Down
6 changes: 3 additions & 3 deletions data_diff/databases/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ def create_connection(self):

pg = import_postgresql()
try:
c = pg.connect(**self._args)
self._conn = pg.connect(**self._args)
if SESSION_TIME_ZONE:
c.cursor().execute(f"SET TIME ZONE '{SESSION_TIME_ZONE}'")
return c
self._conn.cursor().execute(f"SET TIME ZONE '{SESSION_TIME_ZONE}'")
return self._conn
except pg.OperationalError as e:
raise ConnectError(*e.args) from e

Expand Down
10 changes: 8 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@

def run_datadiff_cli(*args):
try:
stdout = subprocess.check_output(
[sys.executable, "-m", "data_diff", "--no-tracking"] + list(args), stderr=subprocess.PIPE
p = subprocess.Popen(
[sys.executable, "-m", "data_diff", "--no-tracking"] + list(args),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout, stderr = p.communicate()
except subprocess.CalledProcessError as e:
logging.error(e.stderr)
raise
if stderr:
raise Exception(stderr)
return stdout.splitlines()


Expand Down Expand Up @@ -48,6 +53,7 @@ def setUp(self) -> None:
def test_basic(self):
conn_str = CONN_STRINGS[self.db_cls]
diff = run_datadiff_cli(conn_str, self.table_src_name, conn_str, self.table_dst_name)

assert len(diff) == 1

def test_options(self):
Expand Down