generalize db interface