pgbelt 0.7.8__tar.gz → 0.7.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {pgbelt-0.7.8 → pgbelt-0.7.10}/PKG-INFO +1 -1
  2. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/logs.py +4 -3
  3. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/postgres.py +12 -7
  4. {pgbelt-0.7.8 → pgbelt-0.7.10}/pyproject.toml +3 -3
  5. {pgbelt-0.7.8 → pgbelt-0.7.10}/LICENSE +0 -0
  6. {pgbelt-0.7.8 → pgbelt-0.7.10}/README.md +0 -0
  7. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/__init__.py +0 -0
  8. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/__init__.py +0 -0
  9. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/convenience.py +0 -0
  10. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/helpers.py +0 -0
  11. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/login.py +0 -0
  12. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/preflight.py +0 -0
  13. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/schema.py +0 -0
  14. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/setup.py +0 -0
  15. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/status.py +0 -0
  16. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/sync.py +0 -0
  17. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/cmd/teardown.py +0 -0
  18. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/config/__init__.py +0 -0
  19. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/config/config.py +0 -0
  20. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/config/models.py +0 -0
  21. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/config/remote.py +0 -0
  22. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/main.py +0 -0
  23. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/__init__.py +0 -0
  24. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/asyncfuncs.py +0 -0
  25. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/dump.py +0 -0
  26. {pgbelt-0.7.8 → pgbelt-0.7.10}/pgbelt/util/pglogical.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pgbelt
3
- Version: 0.7.8
3
+ Version: 0.7.10
4
4
  Summary: A CLI tool used to manage Postgres data migrations from beginning to end, for a single database or a fleet, leveraging pglogical replication.
5
5
  Author: Varjitt Jeeva
6
6
  Author-email: varjitt.jeeva@autodesk.com
@@ -3,12 +3,13 @@ from os import getenv
3
3
  from os import makedirs
4
4
 
5
5
 
6
- FORMATTER = "{name}:{levelname} {message}"
6
+ FORMATTER = "{asctime} {name}:{levelname} {message}"
7
7
 
8
8
  # if this module is ever imported we set up the root logger to log to stderr
9
9
  root_level = int(getenv("LOG_LEVEL", logging.DEBUG))
10
10
  root_handler = logging.StreamHandler()
11
- root_handler.setFormatter(logging.Formatter(FORMATTER, style="{"))
11
+ formatter = logging.Formatter(fmt=FORMATTER, datefmt='%Y-%m-%d %H:%M:%S', style='{')
12
+ root_handler.setFormatter(formatter)
12
13
  root_handler.setLevel(root_level)
13
14
  root_logger = logging.getLogger("dbup")
14
15
  root_logger.setLevel(root_level)
@@ -41,7 +42,7 @@ def get_logger(db: str, dc: str, kind: str = "") -> logging.Logger:
41
42
 
42
43
  if not skip_file_handler:
43
44
  handler = logging.FileHandler(log_file_path(db, dc), mode="w")
44
- handler.setFormatter(logging.Formatter(FORMATTER, style="{"))
45
+ handler.setFormatter(logging.Formatter(FORMATTER, datefmt='%Y-%m-%d %H:%M:%S', style="{"))
45
46
  # always log everything to the file
46
47
  logger.setLevel(logging.DEBUG)
47
48
  logger.addHandler(handler)
@@ -106,17 +106,22 @@ async def compare_data(
106
106
  full_table_name = f'{schema}."{table}"'
107
107
 
108
108
  logger.debug(f"Validating table {full_table_name}...")
109
- order_by_pkeys = ",".join(pkeys_dict[table])
110
109
 
111
- src_rows = await src_pool.fetch(
112
- query.format(table=full_table_name, order_by_pkeys=order_by_pkeys)
110
+ # Have to wrap each pkey in double quotes due to capitalization issues.
111
+ order_by_pkeys = ""
112
+ for pkey in pkeys_dict[table]:
113
+ order_by_pkeys += f'"{pkey}", '
114
+ order_by_pkeys = order_by_pkeys[:-2]
115
+
116
+ filled_query = query.format(
117
+ table=full_table_name, order_by_pkeys=order_by_pkeys
113
118
  )
114
119
 
120
+ src_rows = await src_pool.fetch(filled_query)
121
+
115
122
  # There is a chance tables are empty...
116
123
  if len(src_rows) == 0:
117
- dst_rows = await dst_pool.fetch(
118
- query.format(table=full_table_name, order_by_pkeys=order_by_pkeys)
119
- )
124
+ dst_rows = await dst_pool.fetch(filled_query)
120
125
  if len(dst_rows) != 0:
121
126
  raise AssertionError(
122
127
  f"Table {full_table_name} has 0 rows in source but nonzero rows in target... Big problem. Please investigate."
@@ -144,7 +149,7 @@ async def compare_data(
144
149
  dst_query = f"SELECT * FROM {full_table_name} WHERE "
145
150
 
146
151
  for k, v in pkey_vals_dict.items():
147
- dst_query = dst_query + f"{k} IN ({v}) AND "
152
+ dst_query = dst_query + f'"{k}" IN ({v}) AND '
148
153
 
149
154
  # SELECT * FROM <table> WHERE <pkey1> IN (1,2,3,4,5,6...) AND <pkey2> IN ('a','b','c',...);
150
155
  comparison_query = dst_query[:-5] + f" ORDER BY {order_by_pkeys};"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pgbelt"
3
- version = "0.7.8"
3
+ version = "0.7.10"
4
4
  description = "A CLI tool used to manage Postgres data migrations from beginning to end, for a single database or a fleet, leveraging pglogical replication."
5
5
  authors = ["Varjitt Jeeva <varjitt.jeeva@autodesk.com>"]
6
6
  readme = "README.md"
@@ -22,7 +22,7 @@ black = "~24.8.0"
22
22
  pre-commit = "~3.8.0"
23
23
  flake8 = "^7.1.1"
24
24
  pytest-cov = "~5.0.0"
25
- pytest = "^8.3.2"
25
+ pytest = "^8.3.3"
26
26
  coverage = {extras = ["toml"], version = "^7.6"}
27
27
  safety = "^3.2.7"
28
28
  mypy = "^1.11"
@@ -37,7 +37,7 @@ reorder-python-imports = "^3.13.0"
37
37
  pre-commit-hooks = "^4.6.0"
38
38
  Pygments = "^2.18.0"
39
39
  pyupgrade = "^3.17.0"
40
- pylint = "^3.2.7"
40
+ pylint = "^3.3.1"
41
41
  pytest-asyncio = "~0.24.0"
42
42
 
43
43
  [build-system]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes