From e20e1529af284f4a90b4825a10b7d4433240313a Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Fri, 8 Jan 2021 22:52:12 -0800 Subject: [PATCH] socket connection for postgresql --- .env | 4 +++- app/scripts/delete_photo.py | 1 + app/scripts/get_photo_list.py | 2 ++ app/scripts/process_uploaded_photo.py | 1 + app/scripts/set_contributor_id_seq.py | 1 + app/scripts/totp_utils.py | 3 +++ 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.env b/.env index f2724f8..4a3e4a5 100644 --- a/.env +++ b/.env @@ -10,7 +10,9 @@ LOGGING_XMPP_COMMAND="/usr/bin/sendxmpp" LOGGING_XMPP_USE_TLS=1 # then create postrgresql role and database -DATABASE_URL="postgresql://:@localhost/" +# DATABASE_URL="postgresql://:@localhost/" +# alternatively for unix socket connection +DATABASE_URL="postgresql://:@/?host=/var/run/postgresql" DATABASE_NAME="" DATABASE_USER="" DATABASE_PASSWORD="" diff --git a/app/scripts/delete_photo.py b/app/scripts/delete_photo.py index f1aa347..8c59dfb 100644 --- a/app/scripts/delete_photo.py +++ b/app/scripts/delete_photo.py @@ -8,6 +8,7 @@ def delete_photo(photo, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor() diff --git a/app/scripts/get_photo_list.py b/app/scripts/get_photo_list.py index 1c61c91..082c0c7 100644 --- a/app/scripts/get_photo_list.py +++ b/app/scripts/get_photo_list.py @@ -9,6 +9,7 @@ def find_next_previous(photo, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor() @@ -58,6 +59,7 @@ def get_photo_list(contributor_id, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) diff --git a/app/scripts/process_uploaded_photo.py b/app/scripts/process_uploaded_photo.py index 77e8e6d..5f633d3 100644 --- a/app/scripts/process_uploaded_photo.py +++ b/app/scripts/process_uploaded_photo.py @@ -13,6 +13,7 @@ def process_uploaded_photo(filename, current_user, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor() diff --git a/app/scripts/set_contributor_id_seq.py b/app/scripts/set_contributor_id_seq.py index 626814a..6edd53d 100644 --- a/app/scripts/set_contributor_id_seq.py +++ b/app/scripts/set_contributor_id_seq.py @@ -7,6 +7,7 @@ def set_contributor_id_seq(app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) diff --git a/app/scripts/totp_utils.py b/app/scripts/totp_utils.py index 78b6735..19b361f 100644 --- a/app/scripts/totp_utils.py +++ b/app/scripts/totp_utils.py @@ -13,6 +13,7 @@ def get_totp_qr(contributor, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor() @@ -32,6 +33,7 @@ def validate_totp(contributor, totp_code, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor() @@ -47,6 +49,7 @@ def disable_2fa(contributor, app_config): conn = psycopg2.connect( dbname=app_config['DATABASE_NAME'], user=app_config['DATABASE_USER'], + host="/var/run/postgresql", password=app_config['DATABASE_PASSWORD'] ) cur = conn.cursor()