in reply to using DBD

Not enough information. But most databases have already a tool of this kind. sqlite for sqlite or psql for portgres.
Boris