update sql to check if database exists