Reputation: 3491
I have two programs: the first only write to sqlite db, and the second only read. May I be sure that there are never be some errors? Or how to avoid from it (in python)?
Upvotes: 3
Views: 486
Reputation: 30637
Yes, it is generally safe.
Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time, however.
Since only one of your processes is writing, this is fine.
Exception: This may break if your .sqlite
file is stored on a network drive (Windows or NFS).
Upvotes: 3
Reputation: 6617
generally, it is safe if there is only one program writing the sqlite db at one time. (If not, it will raise exception like "database is locked." while two write operations want to write at the same time.)
By the way, it is no way to guarantee the program will never have errors. using Try ... catch
to handle exception will make the program much safer.
Upvotes: 1