Home > OS >  Is SQLite useful for THIS purpose?
Is SQLite useful for THIS purpose?

Time:03-27

I've written a multi-threaded bot in Python that uses requests.

I want to read and write the output to a file at the same time. You can think of it like an endless loop.

Through research I found out that you can lock and unlock files for other threads. But it doesn't seem to work on Windows, e.g. the fcntl module.

So I'm looking for alternatives. I've never created a database so I'm wondering if SQLite would be suitable for my purpose? That I can read and write the content at the same time without loosing data? :)

CodePudding user response:

Altough the question may be a bit vague, I'll try to answer it anyway.

As SQLite is a transactional Database which complies to the ACID principles:

  1. Atomicity
  2. Consistency
  3. Isolation
  4. Durability

I don't see see a reason why it should not work in your use case.

You should read up on the mentioned principles, as there is an abundance of resources available for doing so I won't bother to try reformulating the definitions here and will provide corresponding URLs instead.

https://en.m.wikipedia.org/wiki/ACID https://www.sqlite.org/transactional.html

  • Related