Skip to content

Commit 82d2f23

Browse files
Merge pull request #47 from OutboundSpade/main
Add database connection pooling
2 parents de6a054 + 1c8f652 commit 82d2f23

5 files changed

Lines changed: 18 additions & 4 deletions

File tree

config/settings/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"default": env.db("DATABASE_URL", default="postgres:///teleband"),
4747
}
4848
DATABASES["default"]["ATOMIC_REQUESTS"] = True
49+
DATABASES["default"]["OPTIONS"] = {"pool": True}
50+
4951
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-DEFAULT_AUTO_FIELD
5052
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
5153

config/settings/local.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
"default": env.db("DATABASE_URL", default="sqlite:///db.sqlite"),
1515
}
1616
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
17-
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1", "dev-api.musiccpr.org", "api.musiccpr.org"])
17+
ALLOWED_HOSTS = env.list(
18+
"ALLOWED_HOSTS",
19+
default=[
20+
"localhost",
21+
"0.0.0.0",
22+
"127.0.0.1",
23+
"dev-api.musiccpr.org",
24+
"api.musiccpr.org",
25+
],
26+
)
1827

1928
# CACHES
2029
# ------------------------------------------------------------------------------

config/settings/production.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
88
SECRET_KEY = env("DJANGO_SECRET_KEY")
99
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
10-
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["https://tele.band", "dev-api.musiccpr.org", "api.musiccpr.org"])
10+
ALLOWED_HOSTS = env.list(
11+
"DJANGO_ALLOWED_HOSTS",
12+
default=["https://tele.band", "dev-api.musiccpr.org", "api.musiccpr.org"],
13+
)
1114

1215
# DATABASES
1316
# ------------------------------------------------------------------------------

requirements/local.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Werkzeug==3.0.3 # https://github.com/pallets/werkzeug
44
ipdb==0.13.13 # https://github.com/gotcha/ipdb
5-
psycopg2-binary==2.9.9 # https://github.com/psycopg/psycopg2
5+
psycopg[binary]>=3.0.0 # https://github.com/psycopg/psycopg
66
watchgod==0.8.2 # https://github.com/samuelcolvin/watchgod
77

88
# Testing

requirements/production.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
wheel==0.43.0 # https://idk
66
gunicorn==22.0.0 # https://github.com/benoitc/gunicorn
7-
psycopg2-binary==2.9.9 # https://github.com/psycopg/psycopg2
7+
psycopg[binary]>=3.0.0 # https://github.com/psycopg/psycopg
88
Collectfast==2.2.0 # https://github.com/antonagestam/collectfast
99

1010
boto3==1.34.145

0 commit comments

Comments
 (0)