From a3dc3bdbf4e4113641e488fc9ea05d7e2676a1c1 Mon Sep 17 00:00:00 2001 From: Bobbe <34186858+30350n@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:46:57 +0100 Subject: [PATCH] Use psycopg2 constants for isolation_level again (#6569) --- InvenTree/InvenTree/settings.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 0e995843f5..5231f4f23b 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -571,6 +571,11 @@ 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, + ) + # Connection timeout if 'connect_timeout' not in db_options: # The DB server is in the same data center, it should not take very @@ -634,7 +639,11 @@ if 'postgres' in db_engine: # pragma: no cover serializable = get_boolean_setting( 'INVENTREE_DB_ISOLATION_SERIALIZABLE', 'database.serializable', False ) - db_options['isolation_level'] = 4 if serializable else 2 + db_options['isolation_level'] = ( + ISOLATION_LEVEL_SERIALIZABLE + if serializable + else ISOLATION_LEVEL_READ_COMMITTED + ) # Specific options for MySql / MariaDB backend elif 'mysql' in db_engine: # pragma: no cover