Skip to content

Commit e2ff44b

Browse files
committed
Add ability to skip the SQLite auto db in combined_run
Signed-off-by: tdruez <[email protected]>
1 parent 47c7aa7 commit e2ff44b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scancodeio/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def combined_run():
106106
configuration.
107107
It combines the creation, execution, and result retrieval of the project into a
108108
single process.
109+
110+
Set SCANCODEIO_NO_AUTO_DB=1 to use the database configuration from the settings
111+
instead of SQLite.
109112
"""
110113
from django.core.checks.security.base import SECRET_KEY_INSECURE_PREFIX
111114
from django.core.management import execute_from_command_line
@@ -114,10 +117,12 @@ def combined_run():
114117
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "scancodeio.settings")
115118
secret_key = SECRET_KEY_INSECURE_PREFIX + get_random_secret_key()
116119
os.environ.setdefault("SECRET_KEY", secret_key)
117-
os.environ.setdefault("SCANCODEIO_DB_ENGINE", "django.db.backends.sqlite3")
118-
os.environ.setdefault("SCANCODEIO_DB_NAME", "scancodeio.sqlite3")
119-
# Disable multiprocessing
120-
os.environ.setdefault("SCANCODEIO_PROCESSES", "0")
120+
121+
# Default to SQLite unless SCANCODEIO_NO_AUTO_DB is provided
122+
if not os.getenv("SCANCODEIO_NO_AUTO_DB"):
123+
os.environ.setdefault("SCANCODEIO_DB_ENGINE", "django.db.backends.sqlite3")
124+
os.environ.setdefault("SCANCODEIO_DB_NAME", "scancodeio.sqlite3")
125+
os.environ.setdefault("SCANCODEIO_PROCESSES", "0") # Disable multiprocessing
121126

122127
sys.argv.insert(1, "run")
123128
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)