2021-03-16 13:36:20 -05:00
|
|
|
import time
|
2024-04-24 09:50:42 -04:00
|
|
|
|
2021-03-16 13:36:20 -05:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.db import connections
|
|
|
|
from django.db.utils import OperationalError
|
|
|
|
|
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
class Command(BaseCommand):
|
2021-03-16 13:36:20 -05:00
|
|
|
def handle(self, *args, **options):
|
2024-04-24 09:43:56 -04:00
|
|
|
db_conn = connections["default"]
|
2021-03-16 13:36:20 -05:00
|
|
|
connected = False
|
|
|
|
while not connected:
|
|
|
|
try:
|
|
|
|
c = db_conn.cursor()
|
|
|
|
connected = True
|
2022-05-10 20:58:47 -04:00
|
|
|
# print("Connected to postgres")
|
2021-07-29 16:24:56 -04:00
|
|
|
except OperationalError as e:
|
2022-05-10 20:58:47 -04:00
|
|
|
print(f" ---> Waiting for db_postgres: {e}")
|
2021-03-16 13:36:20 -05:00
|
|
|
time.sleep(5)
|