A
A
Angope2022-01-12 20:07:43
Python
Angope, 2022-01-12 20:07:43

How to organize a Flask/SQLAlchemy/Python timer?

Good day.
In one of the fields of my database table, I write down the date (the end date of the promotion). I need a function to be called when this date comes. And if it's easier, then I need to set the flag "visibility = False" for it.

What should I know, what to read, what to learn?
Thank you for your attention.

Ps
Anticipating judgmental comments
Programming is a hobby for me. I study like this, I set a task, and as the problem arrives, I already plunge into the study of the issue. Do not judge if the question is banal or incorrectly worded.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2022-01-12
@Angope

And if it's easier, then I need to set the flag "visibility = False" for it.
you do not need to set this checkbox, it is easily calculated when you compare the end date of the promotion with the current one

C
cunning-seal, 2022-01-13
@cunning-seal

If on the forehead: create a background task that goes to the database every N seconds/minutes/days with a query that cuts off rows in which the promotion end date is less than the current date (or if you store it in datetime, then the difference between the current moment and the next one does not exceed limit value) and calls a function for these records
Or maybe, according to the business logic of the application, you don’t need it so much? If you want to receive only those shares that are "active" - ​​well, then put a query to the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question