From 986f75b9228bd38d42eb2a0b11062345955d2730 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 7 Nov 2024 18:52:39 -0800 Subject: [PATCH 1/2] use pg8000, didn't seem to need to upgrade anything --- auth-api/src/auth_api/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth-api/src/auth_api/config.py b/auth-api/src/auth_api/config.py index 3aa3cfb3d8..d5eb4060d2 100644 --- a/auth-api/src/auth_api/config.py +++ b/auth-api/src/auth_api/config.py @@ -80,7 +80,7 @@ class _Config: # pylint: disable=too-few-public-methods f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?unix_sock={DB_UNIX_SOCKET}/.s.PGSQL.5432" ) else: - SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" + SQLALCHEMY_DATABASE_URI = f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" # JWT_OIDC Settings JWT_OIDC_WELL_KNOWN_CONFIG = os.getenv("JWT_OIDC_WELL_KNOWN_CONFIG") @@ -358,4 +358,4 @@ class MigrationConfig: # pylint: disable=too-few-public-methods f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?unix_sock={DB_UNIX_SOCKET}/.s.PGSQL.5432" ) else: - SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" + SQLALCHEMY_DATABASE_URI = f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" From b156d4de2d9cc3194fa767ca8c09fc4ccf8bc1a9 Mon Sep 17 00:00:00 2001 From: Travis Semple Date: Thu, 7 Nov 2024 19:01:07 -0800 Subject: [PATCH 2/2] add pytz, remove use where it's not needed --- auth-api/poetry.lock | 4 ++-- auth-api/pyproject.toml | 1 + auth-api/src/auth_api/models/pubsub_message_processing.py | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auth-api/poetry.lock b/auth-api/poetry.lock index d1ff083d37..05e427a3dd 100644 --- a/auth-api/poetry.lock +++ b/auth-api/poetry.lock @@ -1758,7 +1758,7 @@ packaging = ">=17.0" [package.extras] dev = ["marshmallow[tests]", "pre-commit (>=3.5,<4.0)", "tox"] docs = ["alabaster (==1.0.0)", "autodocsumm (==0.2.13)", "sphinx (==8.0.2)", "sphinx-issues (==4.1.0)", "sphinx-version-warning (==1.1.2)"] -tests = ["pytest", "pytz", "simplejson"] +tests = ["pytest", "simplejson"] [[package]] name = "marshmallow-sqlalchemy" @@ -3319,4 +3319,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "8ce6ca94ca52623956d94232a80831d42d98a03911a066d8f325700089e8cc77" +content-hash = "21d49a011acfb61caf6cda32417fd43bdc009f5e0516e381ccad01ae5fe32491" diff --git a/auth-api/pyproject.toml b/auth-api/pyproject.toml index 9915226e49..1967c19ff0 100644 --- a/auth-api/pyproject.toml +++ b/auth-api/pyproject.toml @@ -26,6 +26,7 @@ cattrs = "^23.2.3" orjson = "^3.10.7" sqlalchemy-utils = "^0.41.2" psycopg2 = "^2.9.9" +pytz = "^2024.2" # VCS dependencies sql-versioning = { git = "https://github.com/bcgov/sbc-connect-common.git", subdirectory = "python/sql-versioning", branch = "main" } diff --git a/auth-api/src/auth_api/models/pubsub_message_processing.py b/auth-api/src/auth_api/models/pubsub_message_processing.py index 5f6f58a4dc..1a957ef82c 100644 --- a/auth-api/src/auth_api/models/pubsub_message_processing.py +++ b/auth-api/src/auth_api/models/pubsub_message_processing.py @@ -4,9 +4,8 @@ Currently used by the account-mailer / auth-queue. This prevents duplicates. """ -import datetime as dt +from datetime import datetime, timezone -import pytz from sqlalchemy import Column, DateTime, Integer, String from .db import db @@ -19,7 +18,7 @@ class PubSubMessageProcessing(db.Model): id = Column(Integer, index=True, primary_key=True) cloud_event_id = Column(String(250), nullable=False) - created = Column(DateTime, default=dt.datetime.now(pytz.utc)) + created = Column(DateTime, default=lambda: datetime.now(tz=timezone.utc)) message_type = Column(String(250), nullable=False) processed = Column(DateTime, nullable=True)