Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to increment an integer at a certain rate over time using a Django powered site and SQLite?

I am trying to display a number that will increment over time that is called from a very, very simple Django database. It will be called using jinja2 templating and the number is a simple IntegerField().

However, I would like for that number to autoincrement, live without refreshing the page, multiple times throughout the day. Also, I would like for every time that the number is refreshed, for the new value to be added to the same database recording the time and date. What is the best combo or group of languages/frameworks to achieve this?

I'm starting to think that Django and Jinja2 alone are not enough to achieve this effect.

like image 331
rook21 Avatar asked Nov 20 '25 05:11

rook21


1 Answers

Maybe this can help: Advanced Python Scheduler

Here's a small piece of code from their documentation to run every hour or configure as crontab:

from apscheduler.schedulers.blocking import BlockingScheduler

def some_job():
    print "Decorated job"

scheduler = BlockingScheduler()
scheduler.add_job(some_job, 'interval', hours=1)
scheduler.start()

Without knowing more of your code it's difficult to say on incremenation but I can suggest

number += 1
like image 147
SpaceCadet Avatar answered Nov 22 '25 17:11

SpaceCadet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!