Use function to get sql connection