diff --git a/InvenTree/InvenTree/management/commands/wait_for_db.py b/InvenTree/InvenTree/management/commands/wait_for_db.py index 198c5dcf73..8709f5315e 100644 --- a/InvenTree/InvenTree/management/commands/wait_for_db.py +++ b/InvenTree/InvenTree/management/commands/wait_for_db.py @@ -7,7 +7,7 @@ from django.core.management.base import BaseCommand from django.db import connections from django.db.utils import OperationalError -import psycopg2 +from part.models import Part import time @@ -26,8 +26,12 @@ class Command(BaseCommand): try: # get the database with keyword 'default' from settings.py db_conn = connections['default'] + + # Try to read some data from the database + Part.objects.count() + # prints success messge in green self.stdout.write(self.style.SUCCESS('InvenTree database connected')) - except (OperationalError, psycopg2.OperationalError): + except: self.stdout.write(self.style.ERROR("Database unavailable, waiting 5 seconds ...")) time.sleep(5)