first rewrite for a more flexible db manager with less hardcoded mysql instructions