Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
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
13 changes: 11 additions & 2 deletions data_diff/__main__.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
from .database import connect_to_uri from .database import connect_to_uri
from .parse_time import parse_time_before_now, UNITS_STR, ParseError from .parse_time import parse_time_before_now, UNITS_STR, ParseError


import rich
import click import click


LOG_FORMAT = "[%(asctime)s] %(levelname)s - %(message)s" LOG_FORMAT = "[%(asctime)s] %(levelname)s - %(message)s"
DATE_FORMAT = "%H:%M:%S" DATE_FORMAT = "%H:%M:%S"


COLOR_SCHEME = {
"+": "green",
"-": "red",
}



@click.command() @click.command()
@click.argument("db1_uri") @click.argument("db1_uri")
Expand All @@ -37,7 +43,9 @@
@click.option("-d", "--debug", is_flag=True, help="Print debug info") @click.option("-d", "--debug", is_flag=True, help="Print debug info")
@click.option("-v", "--verbose", is_flag=True, help="Print extra info") @click.option("-v", "--verbose", is_flag=True, help="Print extra info")
@click.option("-i", "--interactive", is_flag=True, help="Confirm queries, implies --debug") @click.option("-i", "--interactive", is_flag=True, help="Confirm queries, implies --debug")
@click.option("-j", "--threads", default=None, help="Number of threads to use. 1 means no threading. Auto if not specified.") @click.option(
"-j", "--threads", default=None, help="Number of threads to use. 1 means no threading. Auto if not specified."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the default 1 thread? What does auto mean? I think it should be 1 so that the output is nice and expected in the default case. It's also far safer on a relational database where much more could really have an impact (especially with the current queries).

Sorry I know this is not strictly related here, but I must've missed this on the other PR. I thought I read for this when I reviewed the threading PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss it on slack.

)
def main( def main(
db1_uri, db1_uri,
table1_name, table1_name,
Expand Down Expand Up @@ -117,7 +125,8 @@ def main(
print(f"Diff-Split: +{plus} -{minus}") print(f"Diff-Split: +{plus} -{minus}")
else: else:
for op, key in diff_iter: for op, key in diff_iter:
print(op, key) color = COLOR_SCHEME[op]
rich.print(f"[{color}]{op} {key!r}[/{color}]")
sys.stdout.flush() sys.stdout.flush()


end = time.time() end = time.time()
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ python = "^3.7"
runtype = "^0.2.4" runtype = "^0.2.4"
dsnparse = "*" dsnparse = "*"
click = "^8.1" click = "^8.1"
rich = "^10.16.2"



preql = { version = "^0.2.13", optional = true } preql = { version = "^0.2.13", optional = true }
psycopg2 = { version = "*", optional = true } psycopg2 = { version = "*", optional = true }
Expand Down