Skip to content

Commit 0754c16

Browse files
authored
[change] Upgraded from psycopg2 to psycopg 3
1 parent 5fdda4e commit 0754c16

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

images/common/services.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99

1010
def database_status():
11+
import psycopg
12+
1113
try:
12-
psycopg2.connect(
14+
with psycopg.connect(
1315
dbname=os.environ["DB_NAME"],
1416
user=os.environ["DB_USER"],
1517
password=os.environ["DB_PASS"],
@@ -19,8 +21,9 @@ def database_status():
1921
sslcert=os.environ["DB_SSLCERT"],
2022
sslkey=os.environ["DB_SSLKEY"],
2123
sslrootcert=os.environ["DB_SSLROOTCERT"],
22-
)
23-
except psycopg2.OperationalError:
24+
):
25+
pass
26+
except psycopg.OperationalError:
2427
time.sleep(3)
2528
return False
2629
else:
@@ -74,8 +77,6 @@ def redis_status():
7477
arguments = sys.argv[1:]
7578
# Database Connection
7679
if "database" in arguments:
77-
import psycopg2
78-
7980
print("Waiting for database to become available...")
8081
connected = False
8182
while not connected:

images/openwisp_base/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
channels_redis
22
service_identity
33
django-redis
4-
psycopg2
4+
# pool is useful in prod deployments we include it
5+
# by default, but has to be configured manually
6+
psycopg[binary,pool]<4.0.0
57
sentry-sdk
68
supervisor>=4.3.0,<4.4.0
79
django-cors-headers>=4.9.0,<4.10.0

0 commit comments

Comments
 (0)