Combine database connection with query execution