diff options
| author | Alex Schofield <git@ajschof.me> | 2024-08-20 11:31:25 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2024-08-20 11:31:25 +0100 |
| commit | dc3a7e74ddf549dad05745c64201aaf0d3402213 (patch) | |
| tree | 4dd6d629f77171e27408e8cf2f7c06ab6908a098 | |
| parent | 5211751b69a894874945e3a916c33781a327ab10 (diff) | |
| download | de-project-bentley-dc3a7e74ddf549dad05745c64201aaf0d3402213.tar.gz de-project-bentley-dc3a7e74ddf549dad05745c64201aaf0d3402213.zip | |
feat: add advanced logging
| -rw-r--r-- | src/extract_lambda.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/extract_lambda.py b/src/extract_lambda.py index 6216446..9daf662 100644 --- a/src/extract_lambda.py +++ b/src/extract_lambda.py @@ -10,8 +10,12 @@ from botocore.exceptions import ClientError from pg8000.native import Connection, InterfaceError, identifier logger = logging.getLogger(__name__) -logger.setLevel(logging.INFO) - +logging.basicConfig( + format="{asctime} - {levelname} - {message}", + style="{", + datefmt="%Y-%m-%d %H:%M", + level=logging.INFO, +) # DB Exception class @@ -168,11 +172,13 @@ def process_and_upload_tables(db, existing_files, client=boto3.client("s3")): for table in tables: table_name = table[0] - rows = db.run( - f""" + base_query = f""" SELECT * FROM {identifier(table_name)} WHERE last_updated >= :latest; - """, + """ + logger.info(f"Processing table: {table_name}") + rows = db.run( + base_query, latest={ datetime.strftime( latest_timestamp if latest_timestamp else datetime(1990, 1, 1), |
