Working get db connection function