Share db connection logic