adding postgres support, move sql preparation to database class