From f441f672d69a54242ac668930227d0c5c46002d5 Mon Sep 17 00:00:00 2001 From: Bobbe <34186858+30350n@users.noreply.github.com> Date: Mon, 26 Feb 2024 00:58:32 +0100 Subject: [PATCH] Switch tests, docs, database settings from psycopg2 to psycopg (#6573) * Fix isolation_level again, using the recommended method * Use psycopg instead of psycopg2 in tests, docs --- .github/workflows/qc_checks.yaml | 4 ++-- InvenTree/InvenTree/settings.py | 9 +++------ docs/docs/start/install.md | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 12be395d76..50d0b0fa90 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -309,7 +309,7 @@ jobs: uses: ./.github/actions/setup with: apt-dependency: gettext poppler-utils libpq-dev - pip-dependency: psycopg2 django-redis>=5.0.0 + pip-dependency: psycopg django-redis>=5.0.0 dev-install: true update: true - name: Run Tests @@ -391,7 +391,7 @@ jobs: uses: ./.github/actions/setup with: apt-dependency: gettext poppler-utils libpq-dev - pip-dependency: psycopg2 + pip-dependency: psycopg dev-install: true update: true - name: Run Tests diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 5231f4f23b..9e7c94f8ad 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -571,10 +571,7 @@ db_options = db_config.get('OPTIONS', db_config.get('options', {})) # Specific options for postgres backend if 'postgres' in db_engine: # pragma: no cover - from psycopg2.extensions import ( - ISOLATION_LEVEL_READ_COMMITTED, - ISOLATION_LEVEL_SERIALIZABLE, - ) + from django.db.backends.postgresql.psycopg_any import IsolationLevel # Connection timeout if 'connect_timeout' not in db_options: @@ -640,9 +637,9 @@ if 'postgres' in db_engine: # pragma: no cover 'INVENTREE_DB_ISOLATION_SERIALIZABLE', 'database.serializable', False ) db_options['isolation_level'] = ( - ISOLATION_LEVEL_SERIALIZABLE + IsolationLevel.SERIALIZABLE if serializable - else ISOLATION_LEVEL_READ_COMMITTED + else IsolationLevel.READ_COMMITTED ) # Specific options for MySql / MariaDB backend diff --git a/docs/docs/start/install.md b/docs/docs/start/install.md index 71a28843b8..0067dac7a3 100644 --- a/docs/docs/start/install.md +++ b/docs/docs/start/install.md @@ -159,7 +159,7 @@ grant all privileges on database inventree to myuser; The PostgreSQL python binding must also be installed (into your virtual environment): ``` -pip3 install psycopg2 pgcli +pip3 install psycopg pgcli ``` ### MySQL / MariaDB