Reputation: 1065
I've decided to write a little program in Ruby to handle my humble financial tracking needs. It's basically a ledger, a program to track income and expenses and do various kinds of data aggregation. I'm very comfortable in the commandline, which is why I've decided to keep things there, instead of making it a graphical application.
So here's the question: What sort of back end should I use for data storage? I've considered sqlite, but I'm open to suggestions. If I should end up using an SQL database, should I consider using an ORM?
Upvotes: 2
Views: 355
Reputation: 27855
How many data do you have? Do they often change?
For short data sequences, I often combine HERE-documents with YAML.
An example:
require 'yaml'
YAML.load(DATA).each{|account, data|
sum = 0
data.each{|x| sum += x }
puts "%s: %i" % [ account, sum ]
}
__END__
account1:
- 1
- 2
- 3
- 4
account2:
- 10
- 20
- 30
- 40
DATA
is a IO-object and contains the content after END.
This allows you to make data changes inside your script, you don't need a DB-Editor.
If you want to modify the data in your programm and store the results, I recommend - like Benjamin - SQLITE and Sequel.
Upvotes: 0
Reputation: 6120
SQLite could be just fine - it's easy to use from the command line, easy to back up, and easy to version, if you'd need to be able to rollback to a previous state.
There's a nice ORM called Sequel, which I really like when doing non-Rails stuff: http://sequel.rubyforge.org/
Upvotes: 5