0

I have set up MariaDB for the backend database for Ptyhon Django project. As it is in the initial POC stage, I will change the database also if you suggest anything.

There is a table where the user data will be stored for all the entries the users create. And the table contains a data/time field.

I want to trigger email when the date/time field value is equal to current time. Like, if the record1 is having value of tomorrow's 12:31 PM then immediately the email should be triggered to the email ID of the user.

The email sending part we can take care but how to trigger the event when the datetime field value is equal to the current date/time.

One option is to continuously run a background job to check the date/time value but that is not feasible as 1000s of records will be there.

Please suggest, I am a newbie to the Python web projects.

uday kiran
  • 63
  • 5
  • 1
    The way I've done this previously is to have a CronJob that runs every 5 minutes or so and does a query for the datetime being in that 5 minute range. – Tom Hamilton Stubber Sep 10 '20 at 08:50
  • Yeah I thought that, but what happens if two users records have same time then we need to execute the code linearly. But what if 100 users have same time.then there will be delay in the notification. Is there any database concept of creating triggers? – uday kiran Sep 10 '20 at 10:04
  • Does this answer your question? [cron-like recurring task scheduler design](https://stackoverflow.com/questions/3980782/cron-like-recurring-task-scheduler-design) – yolob 21 Sep 10 '20 at 10:35
  • The above solution also requires a background job, is there any database that supports internal triggered feature of it...Like in Postgres we have event to trigger when there is a change in value of the field. But here, value doesn't change in the field but it should trigger when the system time matches the field value. – uday kiran Sep 10 '20 at 10:48

0 Answers0