Update SQL from local database . This is with refactor code