script: use Hash#fetch in database access helpers