Home > Blockchain >  django update database everyday
django update database everyday

Time:11-23

I made a wordlegolf site, www.wordlegolfing.com, where my friends and I play wordle and it tracks our scores daily. I keep track of all the users scores and have a scoreboard shown on the site. If someone forgets to do the wordle that day I currently manually adjust there scores to reflect that but I would like to make it so this is done automatically. I have the site running on heroku currently. Not really looking for exact code but is there something easy to use that could run a program or something that allow me to check if a different field is null each day at midnight and if so save an input

I have tried celery and I cant get it to install

(wordleenv) kyleflannelly@MacBook-Pro-5 wordlegolfing % pip install django-celery 
Collecting django-celery
  Using cached django_celery-3.3.1-py3-none-any.whl (63 kB)
Collecting celery<4.0,>=3.1.15
  Using cached celery-3.1.26.post2-py2.py3-none-any.whl (526 kB)
Requirement already satisfied: django>=1.8 in /Users/kyleflannelly/Dev/environments/wordleenv/lib/python3.10/site-packages (from django-celery) (4.1)
Requirement already satisfied: pytz>dev in /Users/kyleflannelly/Dev/environments/wordleenv/lib/python3.10/site-packages (from celery<4.0,>=3.1.15->django-celery) (2022.2.1)
Collecting kombu<3.1,>=3.0.37
  Using cached kombu-3.0.37-py2.py3-none-any.whl (240 kB)
Collecting billiard<3.4,>=3.3.0.23
  Using cached billiard-3.3.0.23.tar.gz (151 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: asgiref<4,>=3.5.2 in /Users/kyleflannelly/Dev/environments/wordleenv/lib/python3.10/site-packages (from django>=1.8->django-celery) (3.5.2)
Requirement already satisfied: sqlparse>=0.2.2 in /Users/kyleflannelly/Dev/environments/wordleenv/lib/python3.10/site-packages (from django>=1.8->django-celery) (0.4.2)
Collecting amqp<2.0,>=1.4.9
  Using cached amqp-1.4.9-py2.py3-none-any.whl (51 kB)
Collecting anyjson>=0.3.3
  Using cached anyjson-0.3.3.tar.gz (8.3 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in anyjson setup command: use_2to3 is invalid.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

│ exit code: 1 ╰─> [1 lines of output] error in anyjson setup command: use_2to3 is invalid. [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

CodePudding user response:

You don't need Celery to run a daily job.

You do need a script that does what you want. Since you want to interact with the Django database, a custom management command might be your best bet.

Once you have a script that does what you want, you can schedule it to run on your preferred schedule, e.g. daily at 2am.

  • Related