Skip to content

Commit

Permalink
updates psycopg, adds db connection pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmegatelo committed Jan 20, 2025
1 parent 173bad1 commit c832790
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 81 deletions.
6 changes: 3 additions & 3 deletions infra/local/django/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ postgres_ready() {
python << END
import sys
import psycopg2
import psycopg
try:
psycopg2.connect(
psycopg.connect(
dbname="${SQL_DATABASE}",
user="${SQL_USER}",
password="${SQL_PASSWORD}",
host="${SQL_HOST}",
port="${SQL_PORT}",
)
except psycopg2.OperationalError:
except psycopg.OperationalError:
sys.exit(-1)
sys.exit(0)
Expand Down
6 changes: 3 additions & 3 deletions infra/production/django/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ postgres_ready() {
python << END
import sys
import psycopg2
import psycopg
try:
psycopg2.connect(
psycopg.connect(
dbname="${SQL_DATABASE}",
user="${SQL_USER}",
password="${SQL_PASSWORD}",
host="${SQL_HOST}",
port="${SQL_PORT}",
)
except psycopg2.OperationalError:
except psycopg.OperationalError:
sys.exit(-1)
sys.exit(0)
Expand Down
109 changes: 35 additions & 74 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "3.10.9"
django = "^5.1.3"
psycopg2-binary = "^2.9.10"
celery = "^5.4.0"
flower = "^2.0.1"
redis = "^5.2.0"
Expand All @@ -25,6 +24,8 @@ pysocks = "^1.7.1"
django-registration = "^5.1.0"
django-debug-toolbar = "^4.4.6"
djangorestframework = "^3.15.2"
psycopg = "^3.2.4"
psycopg-pool = "^3.2.4"

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.8"
Expand Down
3 changes: 3 additions & 0 deletions walter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
"HOST": os.environ.get("SQL_HOST", "localhost"),
"PORT": os.environ.get("SQL_PORT", "5432"),
"OPTIONS": {
"pool": True,
},
}
}

Expand Down

0 comments on commit c832790

Please sign in to comment.