3 ms·
JSON file (or any file you directly write to) is simple, but has few of the guarantees SQLite gives you with regards to persistence. SQLite abstracts away all o
by dymk 4y ago
JSON file (or any file you directly write to) is simple, but has few of the guarantees SQLite gives you with regards to persistence. SQLite abstracts away all of that for you by handling the fancy platform-specific I/O stuff under the hood.
SQLite does increase complexity in the sense that it's a new dependency. But as far as dependencies go, SQLite has bindings in almost all languages. IMO even for simple usecases, it's worth using it from the start. Refactors are easier down the line than with a bespoke JSON/yaml/flat encoding.
Read only configuration, sure, JSON (etc) file makes sense. The second you start writing to it, probably not.
- fikama 4y agoCould you elaborate more on those things abstracted by SQLite? or point to further reading - You got me interested
- Lex-2008 4y agoNot OP, but I remember reading an interesting article about issues that simple write() might face: https://danluu.com/deconstruct-files/ https://danluu.com/deconstruct-files/ And here's what SQLite does to ensure that in case of application or computer crash database contains either new or old data, but not their mix or some other garbage: https://sqlite.org/atomiccommit.html https://sqlite.org/atomiccommit.html