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
This commit is contained in:
Bobbe 2024-02-26 00:58:32 +01:00 committed by GitHub
parent 18dcc60efd
commit f441f672d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View File

@ -309,7 +309,7 @@ jobs:
uses: ./.github/actions/setup uses: ./.github/actions/setup
with: with:
apt-dependency: gettext poppler-utils libpq-dev 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 dev-install: true
update: true update: true
- name: Run Tests - name: Run Tests
@ -391,7 +391,7 @@ jobs:
uses: ./.github/actions/setup uses: ./.github/actions/setup
with: with:
apt-dependency: gettext poppler-utils libpq-dev apt-dependency: gettext poppler-utils libpq-dev
pip-dependency: psycopg2 pip-dependency: psycopg
dev-install: true dev-install: true
update: true update: true
- name: Run Tests - name: Run Tests

View File

@ -571,10 +571,7 @@ db_options = db_config.get('OPTIONS', db_config.get('options', {}))
# Specific options for postgres backend # Specific options for postgres backend
if 'postgres' in db_engine: # pragma: no cover if 'postgres' in db_engine: # pragma: no cover
from psycopg2.extensions import ( from django.db.backends.postgresql.psycopg_any import IsolationLevel
ISOLATION_LEVEL_READ_COMMITTED,
ISOLATION_LEVEL_SERIALIZABLE,
)
# Connection timeout # Connection timeout
if 'connect_timeout' not in db_options: 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 'INVENTREE_DB_ISOLATION_SERIALIZABLE', 'database.serializable', False
) )
db_options['isolation_level'] = ( db_options['isolation_level'] = (
ISOLATION_LEVEL_SERIALIZABLE IsolationLevel.SERIALIZABLE
if serializable if serializable
else ISOLATION_LEVEL_READ_COMMITTED else IsolationLevel.READ_COMMITTED
) )
# Specific options for MySql / MariaDB backend # Specific options for MySql / MariaDB backend

View File

@ -159,7 +159,7 @@ grant all privileges on database inventree to myuser;
The PostgreSQL python binding must also be installed (into your virtual environment): The PostgreSQL python binding must also be installed (into your virtual environment):
``` ```
pip3 install psycopg2 pgcli pip3 install psycopg pgcli
``` ```
### MySQL / MariaDB ### MySQL / MariaDB