HACKER Q&A
📣 Hammerhead12321

Best option for lightweight data persistence for simple local program?


Hey everyone, I want to build a simple program that will allow me to track my financial “net worth” month to month. It will essentially just take a few numbers from various banking and brokerage accounts every month and compare with the month prior.

It’ll probably just be a script I run locally every month. I’m wondering what the best option might be for saving the account values. A full blown db (sqlite or postgres) sort of seems like overkill, and saving to a text file seems to…fragile? Just wondering if anyone can think of some better options for this use case.


  👤 rhelz Accepted Answer ✓
Reading from sqlite databases can be as fast(or even faster under some conditions) than just reading in files. It's hard to beat for lightweight applications, and should you find you need a little less lightweight storage as your ap evolves, well, you are already using SQL to there is a clear upgrade path.

👤 philipswood
Text files are fine.

Check out plain text accounting:

https://plaintextaccounting.org/


👤 hello_computer
It was once written on the SQLite site:

"SQLite is not designed to replace Oracle. It is designed to replace fopen()."

I recommend it because: A) I never know how far a program is going to go. No point limiting myself to CSV dumps when sqlite is so easy to integrate. B) Less likely to trash my own data using something that has already had so much engineering & QA poured into it. C) It's a standard file format, so it's easier to integrate other programs into the workflow if I ever need to.

But for quick-and-dirty, it's hard to beat plain CSV.


👤 DeathArrow
A file should be good. Why do you think a file is more fragile? DBMS are saving data in files. If you are worried about long term data reliability you can use some error correcting codes such as Hamming or Reed-Solomon. If I do something like this I would use something simple like JSON or CSV.

👤 RetroTechie
Spreadsheet?

👤 pestatije
csv file