I would like to update certain rows in my LSD database. Does anyone now
how this can be accomplished?
Cheers,
Brani
That feature does exist, but is a bit cludgy, undocumented, and prone to
bitrot (it's not used frequently). Thou have been warned :).
That said, one way to do updates is using the INTO clause:
SELECT ... FROM ... INTO table_to_update WHERE dest_col==query_col
The other way is programmatically using table.append() with _update=True
keyword argument:
rows = ... create ndarray or ColGroup of rows to update, with IDs ...
tbl = db.table("table_to_update")
tbl.append(rows, _update=True)
I think Eddie as actually used one of these some point -- maybe he has
better examples?
Cheers,
--
Mario Juric,
Data Mgmt. Project Scientist, Large Synoptic Survey Telescope
Web : http://www.cfa.harvard.edu/~mjuric/
Phone : +1 617 744 9003 PGP: ~mjuric/crypto/public.key
I use table.append(rows, _update=True) fairly frequently, though only
to set or clear a single bit. I think I'm happily breaking some good
practices using qresult_to_table to get the table I want to update,
though, but it was convenient and works.
--
def clear_mask(bounds=None):
query = db.query("select mjd_obs, mask, _id from uberobj")
with db.transaction():
out = query.execute([aux_clear_mask], group_by_static_cell=True)
for x in out:
pass
def aux_clear_mask(qresult):
res = colgroup.fromiter(qresult, blocks=True)
if res.nrows() != 0:
table = qresult_to_table(qresult)
res['mask'] = 0
table.append(res, _update=True)
yield 0
def qresult_to_table(qresult):
return (qresult.tables.values())[0].table
--
Thanks,
Eddie Schlafly