[Nitro] Request for Transaction example
Reid Thompson
Reid.Thompson at ateb.com
Mon Jun 4 14:52:00 EDT 2007
For a simple example's sake, assume i have a file in which space
delimited data correlates to an Og table. The file has +2 Million rows.
How do I setup a transaction to handle the entire file?
I tried something like below, but I think it is committing on every
line, rather all as a transaction... ( Postgresql ).
....
db = Og.setup(og_psql)
store = db.get_store
store.start
myfile = File.open("/home/rthompso/reid")
myfile.each_line {|line|
date, ts, type, telno,t2, location, calltype, fa, fn, result = line.split(' ')
tbl = Loadtbl.new
tbl.date = date
tbl.ts = ts
tbl.type = type
tbl.telno = telno + t2
tbl.location = location
tbl.calltype = calltype
tbl.fa = fa
tbl.fn = fn
tbl.result = result
tbl.save
}
store.commit
....
Thanks,
reid
More information about the Nitro-general
mailing list