Django- Concurrent request handling with db.sqlite3 models, need best approach

291 Views Asked by At

I have developed my first Django web app which pulls data from RTC and displays content in the dash board. I'm storing the data in to sqlite3 DB and from there fetching the data on to the web page.

As this data will get changed frequently, I want to use cron job to periodically (after each 10 min) delete the existing content in the Models and write the latest data. Also, as this will be used by multiple users I wanted to know the best approach to handle concurrency in sqllite3.

There might be chances that users will access the web at the time of deleting and rewriting new content in the models. I realized that select_for_update() will do only row level locking which will only work in other db's like oracle, mysql etc but didn't find sqlite3 there. Moreover in my scenario Do I need table level locking? How would I do it?

I had been through the link https://medium.com/@hakibenita/how-to-manage-concurrency-in-django-models-b240fed4ee2

Where it is given about two approaches Pessimistic (which has row level locking mentioned) and optimistic (Don't think it works in case of multi user, in my scenario)

Please throw some light on the best approach to handle this.

0

There are 0 best solutions below