pgbelt 0.7.9__py3-none-any.whl → 0.7.11__py3-none-any.whl
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.
- pgbelt/util/logs.py +4 -3
- pgbelt/util/postgres.py +28 -6
- {pgbelt-0.7.9.dist-info → pgbelt-0.7.11.dist-info}/METADATA +1 -1
- {pgbelt-0.7.9.dist-info → pgbelt-0.7.11.dist-info}/RECORD +7 -7
- {pgbelt-0.7.9.dist-info → pgbelt-0.7.11.dist-info}/LICENSE +0 -0
- {pgbelt-0.7.9.dist-info → pgbelt-0.7.11.dist-info}/WHEEL +0 -0
- {pgbelt-0.7.9.dist-info → pgbelt-0.7.11.dist-info}/entry_points.txt +0 -0
pgbelt/util/logs.py
CHANGED
|
@@ -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
|
-
|
|
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)
|
pgbelt/util/postgres.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from logging import Logger
|
|
2
2
|
|
|
3
|
+
from decimal import Decimal
|
|
3
4
|
from asyncpg import Pool
|
|
4
5
|
from asyncpg import Record
|
|
5
6
|
from asyncpg.exceptions import UndefinedObjectError
|
|
@@ -171,12 +172,33 @@ async def compare_data(
|
|
|
171
172
|
# Check each row for exact match
|
|
172
173
|
for src_row, dst_row in zip(src_rows, dst_rows):
|
|
173
174
|
if src_row != dst_row:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
|
|
176
|
+
# Addresses #571, AsyncPG is decoding numeric NaN as Python Decimal('NaN').
|
|
177
|
+
# Decimal('NaN') != Decimal('NaN'), breaks comparison. Convert those NaNs to None.
|
|
178
|
+
src_row_d = {
|
|
179
|
+
key: (
|
|
180
|
+
value
|
|
181
|
+
if not (isinstance(value, Decimal) and value.is_nan())
|
|
182
|
+
else None
|
|
183
|
+
)
|
|
184
|
+
for key, value in row.items()
|
|
185
|
+
}
|
|
186
|
+
dst_row_d = {
|
|
187
|
+
key: (
|
|
188
|
+
value
|
|
189
|
+
if not (isinstance(value, Decimal) and value.is_nan())
|
|
190
|
+
else None
|
|
191
|
+
)
|
|
192
|
+
for key, value in row.items()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if src_row_d != dst_row_d:
|
|
196
|
+
raise AssertionError(
|
|
197
|
+
"Row match failure between source and destination.\n"
|
|
198
|
+
f"Table: {full_table_name}\n"
|
|
199
|
+
f"Source Row: {src_row}\n"
|
|
200
|
+
f"Dest Row: {dst_row}"
|
|
201
|
+
)
|
|
180
202
|
|
|
181
203
|
# Just a paranoia check. If this throws, then it's possible pgbelt didn't migrate any data.
|
|
182
204
|
# This was found in issue #420, and previous commands threw errors before this issue could arise.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pgbelt
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.11
|
|
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
|
|
@@ -17,11 +17,11 @@ pgbelt/main.py,sha256=YiagBiGt8pbNlukkRxROXnQX1Tx6ax7c6riuHRCrPYU,186
|
|
|
17
17
|
pgbelt/util/__init__.py,sha256=-6KkvVMz-yGNQfeoo4CZZrgWKXYmFd4CMyoiao8OnFE,40
|
|
18
18
|
pgbelt/util/asyncfuncs.py,sha256=7i_GpBmUNNZ8RUGvU-q5nclsoaCm6Lx8jLP8usYvmZc,583
|
|
19
19
|
pgbelt/util/dump.py,sha256=AwyOAd9CP014gvsl-qlo1lbnXZfxoeN4ujZWUIq7KM8,14715
|
|
20
|
-
pgbelt/util/logs.py,sha256=
|
|
20
|
+
pgbelt/util/logs.py,sha256=E6doEhi8vrusmYUTZRdjKHP-h2dDiExCjgEtMl7epPw,1793
|
|
21
21
|
pgbelt/util/pglogical.py,sha256=Y6KZBeiH85zhNSvhATqh0xozhfUMyQnPWN1HwRosZFo,13613
|
|
22
|
-
pgbelt/util/postgres.py,sha256=
|
|
23
|
-
pgbelt-0.7.
|
|
24
|
-
pgbelt-0.7.
|
|
25
|
-
pgbelt-0.7.
|
|
26
|
-
pgbelt-0.7.
|
|
27
|
-
pgbelt-0.7.
|
|
22
|
+
pgbelt/util/postgres.py,sha256=pDl5CTlLUeuWdQgC_wHbO9Ywd69hHYNaasstog0uzvw,20074
|
|
23
|
+
pgbelt-0.7.11.dist-info/LICENSE,sha256=FQ5cFkW02dKK3LmKH8z-rwn93tWSCh7lsxfNUiWcFsg,10758
|
|
24
|
+
pgbelt-0.7.11.dist-info/METADATA,sha256=-zFOMHxif_8fEFDrHPjwCIR9MPqvHWGwNmUBfQj3yVA,2961
|
|
25
|
+
pgbelt-0.7.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
+
pgbelt-0.7.11.dist-info/entry_points.txt,sha256=SCz_poPjkaVnWpJ-CeytAnDzbVc6l0WalOwitIqW_3g,40
|
|
27
|
+
pgbelt-0.7.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|