db upsert (duplicate key update)

Signed-off-by: Benjamin Mosnier <bm@kappuccino.org>