From be6d71644b38d5f390f87de6a51bae8922b8f9db Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:38:42 -0400 Subject: [PATCH 1/4] Change psycopg2 to psycopg3 --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 543b86b70..d2ff15456 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -3,7 +3,7 @@ Werkzeug[watchdog]==2.3.5 # https://github.com/pallets/werkzeug ipdb==0.13.13 # https://github.com/gotcha/ipdb {%- if cookiecutter.use_docker == 'y' %} -psycopg2==2.9.6 # https://github.com/psycopg/psycopg2 +psycopg[c]==3.1.9 # https://github.com/psycopg/psycopg {%- else %} psycopg2-binary==2.9.6 # https://github.com/psycopg/psycopg2 {%- endif %} From b03cde122171d480bbb5e3c6761bb4b2b8a93d45 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:40:03 -0400 Subject: [PATCH 2/4] Update production.txt --- {{cookiecutter.project_slug}}/requirements/production.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index 36f6e74f5..a45ff8e77 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -3,7 +3,7 @@ -r base.txt gunicorn==20.1.0 # https://github.com/benoitc/gunicorn -psycopg2==2.9.6 # https://github.com/psycopg/psycopg2 +psycopg[c]==3.1.9 # https://github.com/psycopg/psycopg {%- if cookiecutter.use_whitenoise == 'n' %} Collectfast==2.2.0 # https://github.com/antonagestam/collectfast {%- endif %} From dda67d449b2c47258bffc64f8a4917ee8afd1d5d Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:40:43 -0400 Subject: [PATCH 3/4] Update local.txt --- {{cookiecutter.project_slug}}/requirements/local.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index d2ff15456..f180a6cad 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -5,7 +5,7 @@ ipdb==0.13.13 # https://github.com/gotcha/ipdb {%- if cookiecutter.use_docker == 'y' %} psycopg[c]==3.1.9 # https://github.com/psycopg/psycopg {%- else %} -psycopg2-binary==2.9.6 # https://github.com/psycopg/psycopg2 +psycopg[binary]==3.1.9 # https://github.com/psycopg/psycopg {%- endif %} {%- if cookiecutter.use_async == 'y' or cookiecutter.use_celery == 'y' %} watchfiles==0.19.0 # https://github.com/samuelcolvin/watchfiles From 9a74e459e4ab94d237806d9b21c718ae70ab8316 Mon Sep 17 00:00:00 2001 From: Andrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:19:56 -0400 Subject: [PATCH 4/4] Fix entrypoint --- .../compose/production/django/entrypoint | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint index 2fbcad955..dd07f2d2a 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/entrypoint +++ b/{{cookiecutter.project_slug}}/compose/production/django/entrypoint @@ -20,14 +20,14 @@ python << END import sys import time -import psycopg2 +import psycopg suggest_unrecoverable_after = 30 start = time.time() while True: try: - psycopg2.connect( + psycopg.connect( dbname="${POSTGRES_DB}", user="${POSTGRES_USER}", password="${POSTGRES_PASSWORD}", @@ -35,7 +35,7 @@ while True: port="${POSTGRES_PORT}", ) break - except psycopg2.OperationalError as error: + except psycopg.OperationalError as error: sys.stderr.write("Waiting for PostgreSQL to become available...\n") if time.time() - start > suggest_unrecoverable_after: